最佳答案
I reckon this will be quite trivial but I can't work out how to do it. I have a List<int>
and I want to sum a range of the numbers.
Say my list is:
var list = new List<int>()
{
1, 2, 3, 4
};
How would I get the sum of the first 3 objects? The result being 6. I tried using Enumerable.Range
but couldn't get it to work, not sure if that's the best way of going about it.
Without doing:
int sum = list[0] + list[1] + list[2];