QA

   

Q&A

Q1:

Are there any specific cases in which one loop is appropriate over another?

A1:

Usually, when you have to walk an index or sequential set of elements (such as referencing all elements in an array), the for loop is the best choice.

Q2:

Should I be concerned about the performance differences between the two types of loops ?

A2:

With today's fast processors, chances are good that the performance difference between the two loop types in any given situation will be overshadowed by the readability and functionality of the best choice of loop. If you have a situation in which performance is critical, write the loop using all the ways you can think of, benchmark the results, and choose the fastest loop.


   
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