what is the purpose of FOREACH
what is the purpose of FOREACH....example I need
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
om prakashPosted Jul 26, 2013, 7:33 AM
om prakashPosted Jul 26, 2013, 7:31 AM
VulpesPosted Jul 26, 2013, 6:27 AM
However, you can get around this by using the LINQ extension method Reverse() to reverse the order of the collection.
As it's doing more behind the scenes, foreach is also slightly slower than for, though the difference is unimportant in the vast majority of applications.
Sanjeeb LenkaPosted Jul 26, 2013, 6:21 AM
ex:-
using System;
class Program
{
static void Main()
{
// Use a string array to loop over.
string[] ferns =
{
"Psilotopsida",
"Equisetopsida",
"Marattiopsida",
"Polypodiopsida"
};
// Loop with the foreach keyword.
foreach (string value in ferns)
{
Console.WriteLine(value);
}
Console.ReadLine();
}
}