相关疑难解决方法(0)

新的"异常过滤器"功能提供了哪些好处?

C#6有一个名为"异常过滤"的新功能

语法是这样的:

catch (Win32Exception exception) when (exception.NativeErrorCode == 0x00042)  
{  
    //Do something here 
}  
Run Code Online (Sandbox Code Playgroud)

我不禁想知道当前的方法有什么好处:

catch (Win32Exception exception)   
{
     if (exception.NativeErrorCode == 0x00042)
     {
          //Do something here 
     }
}
Run Code Online (Sandbox Code Playgroud)

在大括号之前进行过滤是一件大事吗?也许与性能或安全性有关?

c# exception-handling exception c#-6.0

32
推荐指数
5
解决办法
5302
查看次数

标签 统计

c# ×1

c#-6.0 ×1

exception ×1

exception-handling ×1