C#将一个字符串数组的元素的顺序进行反转

//将一个字符串数组的元素的顺序进行反转。

//{“A”,“B”,”C”,"D","E","F"} {“F”,”E”,”D”,“C”,“B”,”A”}。第i个和第length-i-1个进行交换。

//i      Length-1-0

//i+1     Leng-1-1

//i+2     Leng-1-2

 

string[] names = { "a", "b", "c", "d", "e", "f", "g" };
  for (int i = 0; i < names.Length / 2; i++)
{
  string temp = names[i];
  names[i] = names[names.Length - 1 - i];
  names[names.Length - 1 - i] = temp;
}

  for (int i = 0; i < names.Length; i++)
{
  Console.WriteLine(names[i]);
}
  Console.ReadKey();

 

上一篇:linux下mysql 8.0配置大小写不敏感


下一篇:基于 Django admin 通过后台导出