C#中List调用库函数sort进行升序排序

private void button1_Click(object sender, EventArgs e)
{
List<int> demo2 = new List<int>();
demo2.Add(1);
demo2.Add(56);
demo2.Add(34);
demo2.Add(4);
demo2.Add(5);
demo2.Add(6);
int[] demo3=demo2.ToArray();//z重点是将list转换为arry类型。然后调用arry的sort函数进行排序
Array.Sort(demo3);
int d = demo3.Length;
for(int i=0;i<d;i++)
{
MessageBox.Show(demo3[i].ToString());
}
}

原文地址:https://www.cnblogs.com/hellochenchen/p/5389181.html