Last active
February 15, 2017 18:14
-
-
Save txdv/5f825fdc5b2d2e13680e3667472a6ee5 to your computer and use it in GitHub Desktop.
Can not yield from finally block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
public class MainClass | |
{ | |
public static IEnumerable<string> Actions() | |
{ | |
try { | |
yield return "try"; | |
} catch (Exception) { | |
yield return "catch"; | |
// exceptions.cs(11,4): error CS1631: Cannot yield a value in the body of a catch clause | |
} finally { | |
yield return "finally"; | |
// exceptions.cs(14,4): error CS1625: Cannot yield in the body of a finally clause | |
} | |
} | |
public static void Main(string[] args) | |
{ | |
foreach (var v in Actions()) { | |
Console.WriteLine(v); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment