23
How exactly is foreach implemented in C#?
I imagine a part of it looking like:
var enumerator = TInput.GetEnumerator();
while(enumerator.MoveNext())
{
// do some stuff here
}
However I'm unsure what's really going on. What methodology is used for returning enumerator.Current for each cycle? Does it return [for each cycle] or does it take an anonymous function or something to execute the body of foreach?