Skip to main content
added 2 characters in body
Source Link
McKay
  • 368
  • 4
  • 10

C#

class Foo { static void Main(string[] args) { Bar(); } static IEnumerable<object> Bar() { throw new Exception("I am invincible!"); yield break; } } 

Because the Bar method does a yield, the method doesn't actually run when called, it returns an enumerator which, when iterated,s runs the method.

C#

class Foo { static void Main(string[] args) { Bar(); } static IEnumerable<object> Bar() { throw new Exception("I am invincible!"); yield break; } } 

Because the Bar method does a yield, the method doesn't actually run when called, it returns an enumerator which, when iterated runs the method.

C#

class Foo { static void Main(string[] args) { Bar(); } static IEnumerable<object> Bar() { throw new Exception("I am invincible!"); yield break; } } 

Because the Bar method does a yield, the method doesn't actually run when called, it returns an enumerator which, when iterated,s runs the method.

Source Link
McKay
  • 368
  • 4
  • 10

C#

class Foo { static void Main(string[] args) { Bar(); } static IEnumerable<object> Bar() { throw new Exception("I am invincible!"); yield break; } } 

Because the Bar method does a yield, the method doesn't actually run when called, it returns an enumerator which, when iterated runs the method.