• 关于泛型数据结构中OrderBy的使用


    形如,

    1) ICollection<ImageInfo> imageInfos = new List<ImageInfoDTO>();

      imageInfos = imageInfos.OrderBy(i => i.CreationTime).ToList();

    2)IList<string> fileNameList = new List<string>();

       fileNameList = fileNameList.OrderBy(i => i).ToList();

    此处OrderBy不同于Linq中的OrderBy,需注意。

    附,微软官方定义:

      

    class Pet
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }
    
    public static void OrderByEx1()
    {
        Pet[] pets = { new Pet { Name="Barley", Age=8 },
                       new Pet { Name="Boots", Age=4 },
                       new Pet { Name="Whiskers", Age=1 } };
    
        IEnumerable<Pet> query = pets.OrderBy(pet => pet.Age);
    
        foreach (Pet pet in query)
        {
            Console.WriteLine("{0} - {1}", pet.Name, pet.Age);
        }
    }

    参考自:https://msdn.microsoft.com/en-us/library/bb534966(v=vs.110).aspx
    墨匠
  • 相关阅读:
    Java程序员必知的8大排序
    JQUERY 展开收起显示隐藏效果
    Java程序员必知的8大排序
    辞职申请
    值得收藏的Microsoft SQL Server下的SQL语句
    SQL
    sql language
    insert with special ID
    ExcuteNonQuery
    JS
  • 原文地址:https://www.cnblogs.com/Jashinck/p/7108179.html
Copyright © 2020-2023  润新知