I want to add two lists of a numeric type such that addedList[x] = listOne[x] + listTwo[x]
The output of the list needs to be a Generic.IEnumerable that I can use i
It sounds like you want a function like this:
public static IEnumerable SumIntLists(
this IEnumerable first,
IEnumerable second)
{
using(var enumeratorA = first.GetEnumerator())
using(var enumeratorB = second.GetEnumerator())
{
while (enumeratorA.MoveNext())
{
if (enumeratorB.MoveNext())
yield return enumeratorA.Current + enumeratorB.Current;
else
yield return enumeratorA.Current;
}
// should it continue iterating the second list?
while (enumeratorB.MoveNext())
yield return enumeratorB.Current;
}
}