C# equivalent to VB.NET's Catch…When
问题 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. 回答1: 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. 回答2: There's no