Difference between pre-increment and post-increment in a loop?

a++ is known as postfix. add 1 to a, returns the old value. ++a is known as prefix. add 1 to a, returns the new value. C#: string[] items = {“a”,”b”,”c”,”d”}; int i = 0; foreach (string item in items) { Console.WriteLine(++i); } Console.WriteLine(“”); i = 0; foreach (string item in items) { Console.WriteLine(i++); } … Read more