Sort List in C#

前端 未结 4 1334
没有蜡笔的小新
没有蜡笔的小新 2020-12-18 05:33

So I have this C# list:

List gridMessages = new List();

Each

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 06:01

    The List class has a Sort method which can be used to in place sort the data. One overload takes a Comparison delegate that can be implemented via an anonymous function. For example

    gridMessages.Sort((x, y) => x.Age.CompareTo(y.Age));
    

提交回复
热议问题