C#
class Foo { static void Main(string[] args) { Bar(); } static IEnumerable<object> Bar() { throw new Exception("I am invincible!"); yield break; } } Because the
Barmethod does ayield, the method doesn't actually run when called, it returns an enumerator which, when iterated,s runs the method.