[C#] List 排序 簡單範例

  • 512
  • 0

[C#] List 排序 簡單範例

簡單範例如下:

public class oContact
{
    public string ID { get; set; }
    public string DisplayName { get; set; }
}


List<oContact> ContactList = new List<oContact>();


// 由高到低排序
ContactList .Sort((x, y) => { return -x.ID.CompareTo(y.ID); });

參考網址:https://dotblogs.com.tw/timchang/2012/10/24/78823