hello how r u guys ?
Q: what is the difference between for loop and foreach loop?
kindly describe deeply
Thanks.
Loading
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.
Vilas GitePosted Jul 2, 2011, 1:35 AM
For Loop: Definition, syntax &used of for loop in various languages
http://en.wikipedia.org/wiki/For_loop
Foreach loop :Definition, syntax &used of foreach loop in various languages
http://en.wikipedia.org/wiki/Foreach_loop
----------------------------------------------------------------------------------------------------
If this reply hepls your post…then "MARK AS ANSWER"!
Sandeep ShekhawatPosted Jun 24, 2011, 10:10 AM
{
static void Main(string[] gaju)
{
int[] a = { 1, 2, 3 };
//it is for loop
for(int i=0;i
Console.WriteLine(a[i]);
}
Console.WriteLine("----------");
//it is for each loop
foreach(int i in a)
{
Console.WriteLine(i);
}
Console.Read();
}
OutPut:
Bot gives same out put in above code
VulpesPosted Jun 24, 2011, 10:06 AM
Pradeep ChandrakerPosted Jun 24, 2011, 9:43 AM
http://support.microsoft.com/kb/129931/en-us?p=1
http://diditwith.net/2006/10/05/PerformanceOfForeachVsListForEach.aspx