Skip to content

Instantly share code, notes, and snippets.

@gustavodaquino
Created June 13, 2017 20:28
Show Gist options
  • Save gustavodaquino/9732ca1ad53ccf2b86059770dcf8f32c to your computer and use it in GitHub Desktop.
Save gustavodaquino/9732ca1ad53ccf2b86059770dcf8f32c to your computer and use it in GitHub Desktop.
Compiler-generated code for a foreach loop using the iterator pattern.
List<Person>.Enumerator e = people.GetEnumerator();
try
{
Person v;
while (e.MoveNext())
v = e.Current;
}
finally
{
System.IDisposable d = e as System.IDisposable;
if (d != null) d.Dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment