Do Linq methods on IEnumerable objects stack or do they override previous methods?
For example
string[] exampleArray = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
IEnumerable<string> iEnum1 = exampleArray.Skip(1);
IEnumerable<string> iEnum2 = iEnum1.Take(5);
IEnumerable<string> iEnum3 = iEnum2.Skip(1);
IEnumerable<string> iEnum4 = iEnum3.Take(2);
int count = iEnum4.Count();
Could I expect count
to equal 2 and could I still expect iEnum3
to enumerate over "3", "4", "5", "6"
if I wish to reuse that IEnumerable?
I'm trying to avoid creating new arrays even though they would be logically simpler to work with as the initial array will be relatively large already (from an even larger file stream).