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#的Winforms控件类似于stackoverflow使用的Tags控件(见下文)?
如果没有,你用来处理标签的一些好的替代品是什么?
有人可以告诉我以下两个LINQ语句的区别吗?
var ChkUnique = DB.BusinessFile.FirstOrDefault(c => c.ROCNo == txtBoxID.Text);
Run Code Online (Sandbox Code Playgroud)
和
var ChkUnique = from c in DB.BusinessFile
where c.ROCNo == (string)txtBoxID.Text
select c;
Run Code Online (Sandbox Code Playgroud)
ChkUnique != null
false
当找不到匹配时返回顶部的那个,true
对于后者,我无法弄清楚为什么会发生这种情况.
我是LINQ的新手,所以我可能错过了一些非常基本的东西但是它让我疯狂.