Tag Archives: for loop

Control a loop that uses floating-point values in C#

Sometimes you might need to use a floating-point variable that loop over a range of values. For example, you might want a value to step through the values 0.0 through 1.0 in increments of 0.1. The sequence of numbers would … Continue reading

Posted in calculations, mathematics, variables | Tagged , , , , , , , , , , , , , , | Leave a comment

Loop over entries in an array of unknown length in C#

One way to loop through the items in an array is to hard code its length into the program. Alternatively you can use the array’s Length property to determine how many items it contains at runtime. Then if you later … Continue reading

Posted in arrays, variables | Tagged , , , , , , , , , , , , | Leave a comment

Compare loop performance in C#

The Code Project post FOREACH Vs. FOR (C#) examines the IL code created for a C# foreach loop and a for loop to compare loop performance. The author notices some unnecessary statements in the foreach loop and therefore concludes that … Continue reading

Posted in performance, syntax | Tagged , , , , , , , , , , , | Leave a comment