c# dictionary,list排序

Dictionary Key排序

Dictionary<string, string> dct= new Dictionary<string, string>();

Dictionary<string, string> dctNew = dct.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);

list Key排序

Public class student{

    public int grade
    {
        set;
        get;
    }

    public int age
    {
        set;
        get;
    }

    public string name
    {
        set;
        get;
    }
}  

List<student> students = new List<student>();
students.OrderBy(x=>x.grade).ThenBy(x=>x.age); 

  

猜你喜欢

转载自www.cnblogs.com/yaosj/p/10341402.html