Let me provide an example:
Suppose i have a method:
public void DoStuff(IEnumerable<T> sequence)
{
if (/* is lazy sequence */) throw ...
// Do stuff...
}
And I want to guard against potentially infinite sequences.
Edit:
To elaborate, guarding against infinite collection is only one of the uses. As Jon mentioned. You can easily have infinite IList. Good point.
Other use might be to detect whether data is potentially unrepeatable. Like a random generator. True collection has data already in memory and iterating it twice will give me same data.
Iterators don’t support the IEnumerable<>.Reset() method:
You get a NotSupportedException, which is good, with the Message “Specified method is not supported”, which is tolerable.