I\'ve got a C# string extension method that should return an IEnumerable
of all the indexes of a substring within a string. It works perfectly for it
Enumerators, as the others have said, aren't evaluated until the time they start getting enumerated (i.e. the IEnumerable.GetNext
method is called). Thus this
List indexes = "a.b.c.d.e".AllIndexesOf(null).ToList();
doesn't get evaluated until you start enumerating, i.e.
foreach(int index in indexes)
{
// ArgumentNullException
}