C# GroupBy 用法
生活随笔
收集整理的這篇文章主要介紹了
C# GroupBy 用法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
class Student
{public int StuId { get; set; }public string ClassName { get; set; }public string StudentName { get; set; }
}
static List<Student> studentList = new List<Student>
{new Student {ClassName = "軟工一班", StudentName = "康巴一", StuId = 1},new Student {ClassName = "軟工一班", StudentName = "康巴二", StuId = 2},new Student {ClassName = "軟工一班", StudentName = "康巴三", StuId = 3},new Student {ClassName = "軟工二班", StudentName = "康定一", StuId = 4},new Student {ClassName = "軟工二班", StudentName = "康定二", StuId = 5},new Student {ClassName = "軟工二班", StudentName = "康定三", StuId = 6},
};
發現只能根據一個字段進行 GroupBy,能獲取到分組好的 Student 對象
根據key 值取不同分組:
總結
以上是生活随笔為你收集整理的C# GroupBy 用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 動詞文型調査
- 下一篇: c# char unsigned_dll