score:14

I am not sure why you are messing it up by looping first and writing a query again in the loop. Do it either with a foreach loop or a LINQ query like this:-

int result = items.Sum(x => x.Cost);

It will give you 210 as output.


Related Articles