C#相当于VB.NET的捕捉...当 [英] C# equivalent to VB.NET's Catch...When
本文介绍了C#相当于VB.NET的捕捉...当的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在VB.NET我经常赶上......当
:
In VB.NET I often Catch…When
:
Try
…
Catch e As ArgumentNullException When e.ParamName.ToUpper() = "SAMPLES"
…
End Try
有C#相当于捕捉...当
?
我不希望诉诸使用抓内部的
如果可能的话。如果
语句
I don't want to resort to using an if
statement inside a catch
if possible.
推荐答案
此功能是为宣布C#6.现在可以写
This functionality was announced for C# 6. It is now possible to write
try { … }
catch (MyException e) when (myfilter(e))
{
…
}
您可以下载的的Visual Studio 2015年来检查了这一点,还是等待正式发布。
You can download the preview of Visual Studio 2015 now to check this out, or wait for the official release.
这篇关于C#相当于VB.NET的捕捉...当的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文