zoukankan      html  css  js  c++  java
  • C# into子句

    可使用 into 上下文关键字创建临时标识符,将 groupjoin 或 select 子句的结果存储至新标识符。 此标识符本身可以是附加查询命令的生成器。 有时称在 group 或 select 子句中使用新标识符为“延续”。

    示例

    下面的示例演示使用 into 关键字来启用具有推断类型 IGrouping 的临时标识符 fruitGroup。 通过使用该标识符,可对每个组调用 Count 方法,并且仅选择那些包含两个或更多个单词的组。

    class IntoSample1
    {
        static void Main()
        {
            
            // Create a data source.
            string[] words = { "apples", "blueberries", "oranges", "bananas", "apricots"};
    
            // Create the query.
            var wordGroups1 =
                from w in words
                group w by w[0] into fruitGroup
                where fruitGroup.Count() >= 2
                select new { FirstLetter = fruitGroup.Key, Words = fruitGroup.Count() };
    
            // Execute the query. Note that we only iterate over the groups, 
            // not the items in each group
            foreach (var item in wordGroups1)
            {
                Console.WriteLine(" {0} has {1} elements.", item.FirstLetter, item.Words);
            }
    
            // Keep the console window open in debug mode
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
    /* Output:
       a has 2 elements.
       b has 2 elements.
    */
  • 相关阅读:
    rgb随机颜色函数
    mapshaper转geojson
    postgis
    Draw
    ol 聚类ol.source.Cluster的使用
    ol ---- overlay autoPan的使用
    多层数据注入同一个图层源时,要批量删除某一种要素
    js遍历数组,并从数组中删除元素
    echarts加载geojson
    centos65编译安装lamp和lnmp
  • 原文地址:https://www.cnblogs.com/dehuachenyunfei/p/7772101.html
Copyright © 2011-2022 走看看