I have a code in VB .NET:
Aggregate item In items Into Sum(item.Value)
Could 开发者_如何学运维someone help me to convert it to C#?
This can be done in C# easily via:
var total = items.Sum(item => item.Value);
items.Sum(item => item.Value)
I think
You can alway use http://www.developerfusion.com/tools/convert/vb-to-csharp/ to convert your code, but it's now always reliable.
items.Aggregate((sum, item) => sum += item.Value);
which is the same as:
items.Sum(item => item.Value);
No need to aggregate.
精彩评论