They do "stack" as you put it (typically referred to as "chaining").
Those LINQ statements (Take, Skip) are extensions of IEnumerable, and the end result will be that iEnum4
is exampleArray.Skip(1).Take(5).Skip(1).Take(2)
The final evaluation of that statement is deferred until certain methods are called (such as Count
), at which time the LINQ statement is evaluated and the final result is stored in your int count
variable.
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?
Yes, iEnum3
would evaluate whatever LINQ query it contained, such that iEnum3.Count()
could evaluate to a different value than iEnum4.Count()
. But if you call iEnum3.Count()
three different times in your program, you might get three different results, because the evaluation is deferred and the values in exampleArray
might have changed in the meantime.