1
我想顛倒數組內的字符串元素,但我得到了確切的字符串順序。這裏的代碼顛倒簡單的字符串數組
public static void ReverseArrayElements()
{
Console.WriteLine("This will init array elements and reverse its elements");
string[] elements = { "one, two, three" };
for (int i = 0; i < elements.Length; i++)
{
Console.WriteLine("Array elements before reversing: {0}", elements[i]);
}
Console.WriteLine("\n");
Array.Reverse(elements);
for (int i = 0; i < elements.Length; i++)
{
Console.WriteLine("Array elements after reversing: {0}", elements[i]);
}
Console.ReadLine();
}
結果是一,二,三,再次排序後,一,二,三。
我在這裏做錯了什麼?
正是:)好眼力。 – user1765862