C# equivalent to VB.NET's Catch...When
c#, exception, vb.net, vb.net-to-c#
Solution
This functionality was announced for C# 6. It is now possible to write
try { … }
catch (MyException e) when (myfilter(e))
{
…
}
You can download the preview of Visual Studio 2015 now to check this out, or wait for the official release.
Problem
In VB.NET I often `Catch…When`: ``` Try … Catch e As ArgumentNullException When e.ParamName.ToUpper() = "SAMPLES" … End Try ``` Is there a C# equivalent to `Catch…When`? I don't want to resort to using an `if` statement inside a `catch` if possible.