Nov 29 2011, 06:07 PM
Well done!
I'm currently researching more into C# and noticed there is one more loop style - the For-Each loop. Found in the System.Collections namespace, it is used to iterate through items in a list (array). This is a great implementation which allows easy processing or listing like attributes in said array.
Counter and algorithms can be set in place if certain elements need to be ignored! One can also break from the loop at any time.
Off the MSDN:
I'm currently researching more into C# and noticed there is one more loop style - the For-Each loop. Found in the System.Collections namespace, it is used to iterate through items in a list (array). This is a great implementation which allows easy processing or listing like attributes in said array.
Counter and algorithms can be set in place if certain elements need to be ignored! One can also break from the loop at any time.
Off the MSDN:
Code:
class ForEachTest
{
static void Main(string[] args)
{
int[] fibarray = new int[] { 0, 1, 1, 2, 3, 5, 8, 13 };
foreach (int i in fibarray)
{
System.Console.WriteLine(i);
}
}
}
/*
Output:
0
1
1
2
3
5
8
13
*/