From what I can see, the ForEach
method is available only for the List
class.
Why is that? I can see no reason for ForEach
not to be available to any class implementing the IEnumerable
/IEnumerator
interfaces, and this is a really useful method if you need to perform a small action (1 line is more readable than 1 line + 2 boilerplate foreach syntax...).
Update: I'll clarify my question. There are perfectly valid reasons for including ForEach
in sequences. There are perfectly good reasons for not including ForEach
in all sequences.
But I cannot understand why would ForEach
be included in just some of the sequences.