@
hantsy 既然有比巨人更高的人,那为什么不选择他呢?所以还是惯性,跟语言是否优秀无关。
java8 及之后还是太慢了,还差的远啊,步子还这么小。
我拿我在这里之前的一个回答来举例,按日期分组求和,看看 C#是否简洁明了?
https://dotnetfiddle.net/zUSwU7```
var data = new List<Sample>
{
new Sample {id = 1, date = "02-10", clicks = 1, views = 2},
new Sample {id = 1, date = "02-10", clicks = 2, views = 2},
new Sample {id = 1, date = "02-19", clicks = 3, views = 2},
new Sample {id = 2, date = "02-11", clicks = 4, views = 2},
new Sample {id = 2, date = "02-11", clicks = 5, views = 2},
};
var result = data.GroupBy(i => new {
i.id,
i.date })
.Select(g => new Sample
{
id =
g.Key.id,
date =
g.Key.date,
clicks = g.Sum(i => i.clicks),
views = g.Sum(i => i.views),
});
```