How to Sort a List by a property in the object

前端 未结 20 2013
醉梦人生
醉梦人生 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:36

    //Get data from database, then sort list by staff name:
    
    List staffList = staffHandler.GetStaffMembers();
    
    var sortedList = from staffmember in staffList
                     orderby staffmember.Name ascending
                     select staffmember;
    

提交回复
热议问题