why not int[ ] a = new int[10]; int k=0; for (; k < 10; k++) { a[k] = k*2; } foreach (k in a) { Console.WriteLine(k); } | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why not int[ ] a = new int[10]; int k=0; for (; k < 10; k++) { a[k] = k*2; } foreach (k in a) { Console.WriteLine(k); }

6th Jul 2016, 6:11 AM
Abdelrahman
Abdelrahman - avatar
2 Answers
+ 1
No you can........see (conditional and loops /The for loop/ page 3)
6th Jul 2016, 9:46 PM
Abdelrahman
Abdelrahman - avatar
0
foreach statement must include both type & identifier .
6th Jul 2016, 6:13 AM
Abdelrahman
Abdelrahman - avatar