• LINQ


    var racers = Formula1.GetChampions().
                    Where(r => r.Wins > 15 && (r.Country == "Brazil" || r.Country == "Austria")).
                    Select(r=>r);
                foreach (var item in racers)
                {
                    Console.WriteLine("{0:A}",item);
                }

    索引传递

    var racers = Formula1.GetChampions().Where((r, index) => r.LastName.StartsWith("A") && index % 2 != 0);
                foreach (var item in racers)
                {
                    Console.WriteLine("{0:A}", item);
                }

    linq分组、排序、选择特定值(其中Coun,C可以理解为结果的属性)

    var country = Formula1.GetChampions().GroupBy(r => r.Country).OrderByDescending(g => g.Count()).
    ThenBy(g => g.Key).Where(g => g.Count() > 2).Select(g => new { Coun = g.Key, C = g.Count() });

    分页分区

    int pageSize = 5;
    int pageNumber = (int)Math.Ceiling(Formula1.GetChampions().Count() / (double)pageSize);
    for (int page = 0; page < pageNumber; page++)
    {
    Console.WriteLine("page {0}",page);
    var racers = (from r in Formula1.GetChampions() orderby r.LastName select r.FirstName + " " + r.LastName).Skip(page * pageSize).Take(pageSize);
    foreach (var item in racers)
    {
    Console.WriteLine(item);
    }
    }

  • 相关阅读:
    新版本NDK环境结构(避Cygwin,超快)
    网络、会话建立与信任
    网络协议与语言
    网络通信协议--网络通用语言
    语法、语义与哲学
    虚连接 tcp
    TCP的可靠连接是如何产生的?
    一个TCP的问题,所谓TCP面向连接的虚电路到底是怎么实现的?
    TCP与虚连接
    网络发展史介绍
  • 原文地址:https://www.cnblogs.com/yj2010/p/4122779.html
Copyright © 2020-2023  润新知