Posted November 21, 20186 yr The version lower than C#6 compiler can produce the Endfilter Opcode? What C# code? Version higher than C#6 can produce the Endfilter Opcode. try { throw new ApplicationException("Error"); } catch (ApplicationException ex) when (ex.Message == "Error") { Console.WriteLine("OK"); } Edited November 21, 20186 yr by Perplex
November 21, 20186 yr Exception filters were added to C# in v6, so you need to use a compiler and such that supports it. VS2015 was the main IDE that included and supported it first, then any edition afterward. However, you can manually use the Roslyn compiler to support it in any version as well: https://github.com/dotnet/roslyn But if you are looking to target C# 5 or lower, then you will not be able to use the feature. (The .NET framework and it's various libs are open source now so you can technically manually go add the features you want to a lower version of the framework but it would be non-standard and unsupported on others systems.)
Create an account or sign in to comment