开发者

How to express VB .NET "Aggregate Into" in C#?

开发者 https://www.devze.com 2023-03-23 07:04 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消