I need to move backwards through an array, so I have code like this:
for (int i = myArray.Length - 1; i >= 0; i--) { // Do something myArray[i] =
I'd use the code in the original question, but if you really wanted to use foreach and have an integer index in C#:
foreach (int i in Enumerable.Range(0, myArray.Length).Reverse()) { myArray[i] = 42; }