Oliver Gargour <ne********@garwin.be> wrote:
Is at all possible to get IEnumerable Item Count without having to loop
through using GetEnumerator() ??
Not in general. There may not even be a sensible meaning to that. For
instance, it would be possible (potentially useful even) to write an
IEnumerable implementation on top of TextReader, so you could do:
foreach (string line in new LineReader(myTextReader))
{
}
Now, potentially that TextReader is coming over a network connection
which may keep giving text forever.
Alternatively, a random number generator could implement IEnumerable -
again, no sensible concept of count.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too