Summary


In this hour, you learned how a method is a discrete set of code designed to perform a task or related set of tasks. Methods are where you write Visual C# code. Some methods might be as short as a single line of code, whereas others will be pages in length. You learned how to define procedures and how to call them; creating and calling procedures is critical to your success in programming with Visual C#. Be sure to avoid creating recursive procedures! Because you use procedures so often, they'll become second nature to you in no time.

Classes are used to group related procedures. In this hour, I focused on the using the form class you've been working with all along. In Hour 16, you'll build on your experience with classes and work with classes to create new objects, which demands good segregation of discrete methods.

Did you Know?

Keep in mind that every method should perform a specific function; avoid creating methods that perform many different tasks. For example, suppose that you want to create a set of code that draws an ellipse on a form. Consider that you also want to clear the form. If you placed both sets of code in the same method, the ellipse would be drawn and then immediately erased. By placing each set of code in its own method, you can draw the ellipse by calling one method and then erase it at any time by calling the other method. By placing these routines in a new class rather than attaching them to a specific form class, you also make the methods available to any form that needs them.





Sams Teach Yourself Microsoft Visual C# 2005 in 24 Hours, Complete Starter Kit
Sams Teach Yourself Visual C# 2005 in 24 Hours, Complete Starter Kit
ISBN: 0672327406
EAN: 2147483647
Year: N/A
Pages: 248
Authors: James Foxall

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net