I am trying to understand what goes wrong in the following piece of code.
var signals = new List<List<double>>
{
new List<double> {1, 2, 3},
new List<double> {2, 3, 4},
};
var enumerators = signals.Select(l => l.GetEnumerator()).ToList();
if (enumerators.All(enumerator => enumerator.MoveNext()))
{
var cummulative = enumerators.Sum(enumerator => enumerator.Current);
}
Why are both enumerators pointing to the current value 0? I would expect both would point to the first number in the list, which would be 1 and 2 respectively.
Each time I access the enumerator via linq it seems to restart. Why?