C#将一个字符串数组的元素的顺序进行反转
2021-01-15 03:14
标签:temp OLE key nbsp 顺序 for 反转 mes line //将一个字符串数组的元素的顺序进行反转。 //{“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 { C#将一个字符串数组的元素的顺序进行反转 标签:temp OLE key nbsp 顺序 for 反转 mes line 原文地址:https://www.cnblogs.com/momj/p/14273747.html
for (int i = 0; i {
string temp = names[i];
names[i] = names[names.Length - 1 - i];
names[names.Length - 1 - i] = temp;
}
Console.WriteLine(names[i]);
}
Console.ReadKey();
文章标题:C#将一个字符串数组的元素的顺序进行反转
文章链接:http://soscw.com/index.php/essay/42072.html