使用orderby或sort对通用列表进行排序

时间:2017-03-28 16:17:10

标签: c# list generics

我有一个具有这种结构的通用列表:

        public class Emoticon
    {
        public int id { get; set; }
        public string code { get; set; }
        public string emoticon_set { get; set; }
    }

    public class Emoticons
    {
        public List<Emoticon> emoticons { get; set; }
    }

列表为Emoticons twitch_emoticons。不,我想按ID对列表进行排序。有谁可以帮助我?

1 个答案:

答案 0 :(得分:2)

添加名称空间,

  using System.Linq;

然后尝试,

var result = twitch_emoticons.OrderBy(res => res.id).ToList();
相关问题