• GroupBy


    string[] Words = new string[] { "what", "is", "your", "name", "?", "my", "name", "is", "lyf","." };
    var Groups = from word in Words
                        group word by word.Length into lengthGroups //按单词长度将单词分组
                        orderby lengthGroups.Key descending //按单词长度降序排列
                        select new
    {
       Length = lengthGroups.Key, //取单词长度
       WordCollect = lengthGroups //取该长度的单词分组集合
    };
    foreach (var group in Groups) //遍历每组单词
    {
       Response.Write("包含" + group.Length.ToString() + "个字符的单词有:" + "<br/>");
       foreach (string word in group.WordCollect)
       {
          Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;" + word + "<br/>");
       }
    }

  • 相关阅读:
    Java8新特性学习笔记(一) Lambda表达式
    android游戏动画特效的一些处理
    start from here
    感知机回归
    2020/2/21
    梯度下降
    凸优化
    批量归一化和残差网络
    Momentum
    词嵌入基础
  • 原文地址:https://www.cnblogs.com/Yellowshorts/p/2867644.html
Copyright © 2020-2023  润新知