Array.Reverse(str);//反转整个数组中元素的顺序
实现原理 :
static void Main(string[] args)
{
string[] str = {"a","u","c","d","e","b" };
for (int i = 0; i < str.Length/2; i++)
{
//无论数组元素个数是奇数还是偶数,都交换Length/2次
string temp = str[i];
str[i] = str[str.Length - 1 - i];//交换变量的值
str[str.Length - 1 - i] = temp;
}
for (int i = 0; i < str.Length; i++)
{
Console.WriteLine(str[i]);
}
Console.ReadKey();
}