Sorting an IList in C#

前端 未结 15 2376
臣服心动
臣服心动 2020-11-28 06:36

So I came across an interesting problem today. We have a WCF web service that returns an IList. Not really a big deal until I wanted to sort it.

Turns out the IList

15条回答
  •  被撕碎了的回忆
    2020-11-28 06:55

    using System.Linq;
    
    var yourList = SomeDAO.GetRandomThings();
    yourList.ToList().Sort( (thing, randomThing) => thing.CompareThisProperty.CompareTo( randomThing.CompareThisProperty ) );
    

    That's pretty !ghetto.

提交回复
热议问题