Linq SUM on objects?

后端 未结 3 772
星月不相逢
星月不相逢 2021-01-17 21:59

I\'ve an object that represent a business data.

Basically, it\'s an object agregating some totals:

public class MyClass{
   public double MyDataOne {         


        
3条回答
  •  粉色の甜心
    2021-01-17 22:24

    In order to use Sum you should provide Func delegate, where ### is int, long, float, double, decimal or their nullable counterparts. So you are not able to use MyClass in the way you want.

    All overloads of Sum method returns primitive types that I mentioned above. That's why it doesn't make sense to sum custom object while returning type is not a number but custom object too.

提交回复
热议问题