C#:Array.Sort方法的两倍?

Flo*_* M. 1 c# arrays sorting

我有一个数组(double):ox_test具有已知数量的元素。

当我编码时:

Array.Sort(ox_test);
Run Code Online (Sandbox Code Playgroud)

然后,仅查看数组是否已排序:

for (int y = 1; y <= ox_test.Length; y++)
     MessageBox.Show(".x: " + ox_test[y]);
Run Code Online (Sandbox Code Playgroud)

..我得到... 0、0、0、0、0(如果元素数为5)。请帮忙,谢谢!

所以我修改了两个for循环:

for (int y = 0; y < ox_test.Length; y++)
    MessageBox.Show(".x: " + ox_test[y]);
    // HERE  i get the values not sorted but != 0

Array.Sort(ox_test);

for (int y = 0; y < ox_test.Length; y++)
    MessageBox.Show(".x s: " + ox_test[y]);
    // HERE i get only 0 values
Run Code Online (Sandbox Code Playgroud)

dun*_*lli 5

// sort double array
double[] doubleArray = new double[5] { 8.1, 10.2, 2.5, 6.7, 3.3 };
Array.Sort(doubleArray);
// write array
foreach (double d in doubleArray) Console.Write(d + " ");  // output: 2.5 3.3 6.7 8.1 10.2
Run Code Online (Sandbox Code Playgroud)