【发布时间】:2014-06-21 18:25:08
【问题描述】:
我作为以前的 c++ 编码员在 c# 中输入其他人的代码库。在他的代码中,我发现 sn-ps 看起来像这样:
MethodInvoker invoker = new MethodInvoker
(delegate()
{
...
}
);
try
{
this.Invoke(invoker);
}
catch (Exception x)
{
...
}
我的问题是:是否有任何理由使用 delegate 然后 try-catch?第三到第五行花括号内的代码可以不只是放在try catch中吗?是否有一些我还不知道的 c# 细微差别?
【问题讨论】: