int[] myarray = new int[]{1,2,3,4};
for(int i = myarray.Length - 1; i >= 0; i--)
{
Console.WriteLine(i);
}
for (int i = 0; i < arr.Length / 2; i++)
{
int tmp = arr[i];
arr[i] = arr[arr.Length - i - 1];
arr[arr.Length - i - 1] = tmp;
}
using System;
public class Example
{
public static void Main()
{
int[] array = { 2, 4, 6, 8 };
Array.Reverse(array);
Console.WriteLine(String.Join(',', array));
}
}
/*
Output: 8,6,4,2
*/
for (int i = myArray.Length; i --> 0; )
{
//do something
}
string[] arr = new string[5];
for (int a = arr.Length; --a >= 0;)
{
// ...
}