Last active
November 10, 2018 06:20
-
-
Save kekyo/abcb76d0ca4ae31c972bdf676bded123 to your computer and use it in GitHub Desktop.
What kind of order did we handle exception with filter expressions.
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; | |
namespace ExceptionTest | |
{ | |
class Program | |
{ | |
static string GetMessage(Exception ex, string banner) | |
{ | |
Console.WriteLine(banner); | |
return ex.Message; | |
} | |
static void Main(string[] args) | |
{ | |
try | |
{ | |
try | |
{ | |
// C D B E F H | |
throw new Exception("111"); | |
// C D [Unhandled exception] | |
//throw new Exception("333"); | |
} | |
catch (Exception ex) when (GetMessage(ex, "C") == "222") | |
{ | |
Console.WriteLine("A"); | |
} | |
finally | |
{ | |
Console.WriteLine("B"); | |
} | |
Console.WriteLine("G"); | |
} | |
catch (Exception ex) when (GetMessage(ex, "D") == "111") | |
{ | |
Console.WriteLine("E"); | |
} | |
finally | |
{ | |
Console.WriteLine("F"); | |
} | |
Console.WriteLine("H"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment