当前位置:网站首页>[linq]c list type grouping sum
[linq]c list type grouping sum
2022-06-28 21:49:00 【Xiamen dezai】
C# List Type group summation
List<Person> personList = new List<Person>();
Person p1 = new Person();
p1.Name = "Bob";
p1.Age = "14";
p1.Salary = 1200;
personList.Add(p1);
Person p2 = new Person();
p2.Name = "Bob";
p2.Age = "14";
p2.Salary = 1500;
personList.Add(p2);
Person p3 = new Person();
p3.Name = "Ken";
p3.Age = "56";
p3.Salary = 1000;
personList.Add(p3);
var groupList = personList.GroupBy(m => new {
m.Name, m.Age }).
Select(a => new
{
Name = a.Key.Name,
Salary = a.Sum(c=>c.Salary)
}).ToList();
foreach (var item in groupList)
{
Console.WriteLine("Name:{0}--Salary:{1}", item.Name,item.Salary);
}
Console.ReadKey();
边栏推荐
- pyechart绘制多条y轴折线图
- Pyechart drawing multiple Y-axis line graphs
- QJsonObject的使用示例
- LeetCode1114. 按序打印
- SqlTransaction
- Is the rapid SSL wildcard certificate genuine in 1981
- Biovendor free light chain( κ and λ) Test steps of ELISA Kit
- go-cryptobin 常用加密解密库
- Real time transformer: meituan's research on single image depth estimation
- Lumiprobe proteorange protein gel dye instructions
猜你喜欢

I almost ran away

Study on bifunctional crosslinker lumiprobe sulfoacyanine 7 dicarboxylic acid

Application practice | 1billion data second level correlation. Huolala's OLAP System Evolution Based on Apache Doris (with PPT download)

How to analyze the relationship between enterprise digital transformation and data asset management?

How to analyze the relationship between enterprise digital transformation and data asset management?

What is an interface? What is interface testing?

The further application of Li Kou tree

安全 创新 实践|海泰方圆受邀参加“数字时代的网信创新与价值共创”技术交流研讨会

Mongodb - replica set and sharding

PHP uses stack to solve maze problem
随机推荐
Is the inter-bank certificate of deposit reliable and safe
LeetCode121. The best time to buy and sell stocks
Building web automation environment
Microsoft's exclusive payment function has also been perfectly unlocked
什么是接口?什么是接口测试?
Alist+raidrive gives the computer a complete 8billion GB hard disk drive
LeetCode226. 翻转二叉树
16 `bs object Node name Div. attribute contents ` children descendants get child nodes and descendants
LeetCode986. 区间列表的交集
Openfire 3.8.2 cluster configuration
17 `bs object Node name h3 Parent ` parents get parent node ancestor node
Pie (poj3122) super detailed and easy to understand binary introduction
Is it safe to open a stock trading account? Is it reliable?
安全 创新 实践|海泰方圆受邀参加“数字时代的网信创新与价值共创”技术交流研讨会
Query rewriting for opengauss kernel analysis
力扣树的进一步应用
Pyechart drawing multiple Y-axis line graphs
go-cryptobin 常用加密解密库
To be a cross-border e-commerce, you must learn to use PRA software, free your hands and improve efficiency!
postman简介与安装步骤