C#中的简单问题
问题描述:
大家好,
谁能告诉我下面是什么样的东西:
Hi all,
can anyone told me that Kind of sort is it below:
string[] data = listbox1.Items.Cast<string>().ToArray();
ArrayList arr = new ArrayList();
foreach (string s in data)
if (!s.StartsWith(" "))
arr.Add(s);
arr.Sort();
listBox2.DataSource = arr;
我介意它是否可以调用快速排序或.... ??
thnx
I mind if it can call quick sort or....??
thnx
答
如果您问ArrayList.Sort使用哪种排序,它将使用Quicksort.
请参阅此链接中的备注"部分: http://msdn.microsoft.com/en-us/library/8k6e334t.aspx [ ^ ]
If you are asking what kind of sort is used by ArrayList.Sort, it uses Quicksort.
See the Remarks section in this link: http://msdn.microsoft.com/en-us/library/8k6e334t.aspx[^]
如解决方案1所述,mscorblib.dll的System.Array类的Sort方法内部使用了QuickSort,如下所示,
As mentioned in the solution 1, Sort method of the System.Array class of mscorblib.dll used QuickSort internally as showing below,
IL_0128: call instance void System.Array/SorterGenericArray::QuickSort(int32,
int32)
希望对您有所帮助:)
Hope it helps :)