Summary

   

Looping is a powerful technique that allows you to write tighter code. Tighter code is code consisting of fewer lines, is more efficient, and is usually ”but not always ”more readable. In this hour , you learned to write for loops for situations in which you know the precise number of times you want a loop executed. Remember, it's not necessary to know the number of iterations at design time, but you must know the number at runtime to use a for loop. You learned how to use iterators to increment the counter of a for loop, and even how to exit a loop prematurely using break.

In this hour, you also learned how to use the very powerful do while loop. The do while loop enables you to create very flexible loops that can handle almost any looping scenario. You learned how evaluating expression in a do while loop makes the loop behave differently than when evaluating the expression in a while do loop. If a for loop can't do the job, some form of the do while or while do loop will.

In addition to learning the specifics about loops, you've seen firsthand how multiple solutions to a problem can exist. Often, one approach is clearly superior to all other approaches, although you may not always find it. Other times, one approach may be only marginally superior , or multiple approaches may all be equally applicable . Expert programmers are able to consistently find the best approaches to any given problem. With time, you'll be able to do the same.


   
Top


Sams Teach Yourself C# in 24 Hours
Sams Teach Yourself Visual Basic 2010 in 24 Hours Complete Starter Kit (Sams Teach Yourself -- Hours)
ISBN: 0672331136
EAN: 2147483647
Year: 2002
Pages: 253
Authors: James Foxall

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