Perplex Posted November 21, 2018 Posted November 21, 2018 (edited) 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, 2018 by Perplex
kao Posted November 21, 2018 Posted November 21, 2018 Before VS2015 only Visual Basic .NET compiler used exception filters.
atom0s Posted November 21, 2018 Posted November 21, 2018 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.)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now