Major and importance difference between for and foreach loop ?
antony romar
a for loop is a construct that says "perform this operation n. times".a foreach loop is a construct that says "perform this operation against each value/object in this IEnumerable"
yes
For Loop static int Method1(int[] array) {int a = 0;for (int i = 0; i < array.Length; i++){a += array[i];}return a; }Foreach loop static int Method2(int[] array) {int a = 0;foreach (int value in array){a += value;}return a; }