小编low*_*ern的帖子

在catch区块返回?

在catch块中有一个return语句是错误的吗?有哪些替代方案?
即:

public bool SomeFunction()
{
    try
    {
        //somecode
        return true;
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.message);
        return false;
    }

}
Run Code Online (Sandbox Code Playgroud)

.net c# exception-handling

58
推荐指数
5
解决办法
4万
查看次数

标签 统计

.net ×1

c# ×1

exception-handling ×1