How to Sort a List by a property in the object

前端 未结 20 1987
醉梦人生
醉梦人生 2020-11-21 08:25

I have a class called Order which has properties such as OrderId, OrderDate, Quantity, and Total. I have a l

20条回答
  •  醉话见心
    2020-11-21 08:47

    Anybody working with nullable types, Value is required to use CompareTo.

    objListOrder.Sort((x, y) => x.YourNullableType.Value.CompareTo(y.YourNullableType.Value));

提交回复
热议问题