I have a class here that I want to sum(for every Traid T in list)(T.Price*T.Buy). (Buy is +1 if it is a Buy, -1 one if a sell). So for instance if I have {Buy=-1,Price=10} and {Buy=1, price is =4} I would get -6. I want an eloquent way to do this, I am assuming I should do some kind of overloading? I’m new to programming and haven’t done this before. Thanks in advance.
-Rik
private class Traid
{
public DateTime Date { get; set; }
public int Index { get; set; }
public int Buy { get; set; }
public int Price {get;set;}
}
You can use
Enumerable.Sum: