[C#] C#通过委托给列表排序 →→→→→进入此内容的聊天室

来自 , 2021-01-19, 写在 C#, 查看 133 次.
URL http://www.code666.cn/view/3e6ad89f
  1. // Create a simple example list
  2. List<string> TestList = new List<string>();
  3.  
  4. TestList.Add("Venezuela");
  5. TestList.Add("Norway");
  6. TestList.Add("Finland");
  7. TestList.Add("Brazil");
  8. TestList.Add("Germany");
  9. TestList.Add("Australia");
  10. TestList.Add("Fakeland");
  11.  
  12.  
  13. // Sort the list by A-Z
  14. TestList.Sort(delegate(string A, string B) {
  15.     return A.CompareTo(B);
  16. });
  17.  
  18. // Print out the test list
  19. foreach (string Country in TestList)
  20.     Console.WriteLine(Country);
  21.  
  22. /*
  23. Results:
  24.  
  25. Australia
  26. Brazil
  27. Finland
  28. Germany
  29. Norway
  30. Venezuela
  31. */
  32. //csharp/2046

回复 "C#通过委托给列表排序"

这儿你可以回复上面这条便签

captcha