我想可以使用Attribute进行异常处理,而不是在每个方法中写"try ... catch".
例如,现在,我的每个方法都是这样的:
public void DoSomething()
{
try
{
// do something
}
catch (Exception ex)
{
// exception handling rules, always the same.
throw;
}
}
Run Code Online (Sandbox Code Playgroud)
我想要:
[HandleException]
public void DoSomething()
{
// do something
}
Run Code Online (Sandbox Code Playgroud)
可能吗?
| 归档时间: |
|
| 查看次数: |
2358 次 |
| 最近记录: |