Summary


Looping is a powerful technique that enables you to write tighter code. Tighter code is smaller, more efficient, and usuallybut not alwaysmore 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 loop. If a for loop can't do the job, some form of the do...while or while 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.




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