C#通过委托给列表排序的代码

如下的内容是关于C#通过委托给列表排序的内容。

List TestList = new List();

TestList.Add(“Venezuela”);
TestList.Add(“Norway”);
TestList.Add(“Finland”);
TestList.Add(“Brazil”);
TestList.Add(“Germany”);
TestList.Add(“Australia”);
TestList.Add(“Fakeland”);

TestList.Sort(delegate(string A, string B) {
return A.CompareTo(B);
});

foreach (string Country in TestList)
Console.WriteLine(Country);

Results:

Australia
Brazil
Finland
Germany
Norway
Venezuela

猜你喜欢

转载自blog.csdn.net/weixin_44281775/article/details/89632866