What is the precise implementation of Enumerable.Range in .Net; preferable .Net 4? Is it a yielded for-loop? A custom implementation (IEnumerable, IEnumerator) or?<
A slight but significant difference in the Reflector output (as well as the argument check and extra level of internalisation mentioned in CraigTP's answer and its comments):
public static IEnumerable Range(int start, int count) {
for(int current = 0; current < count; ++current) {
yield return start + current;
}
}
That is, instead of another local variable, they apply an extra addition for every yield.