Do you actually need more information than plain IEnumerable
gives you? Just cast it to that and use foreach
with it. I face exactly the same situation in some bits of Protocol Buffers, and I've found that casting to IEnumerable
(or IList
to access it like a list) works very well.