小编Pra*_*nth的帖子

如果没有异常,是否可以有条件地执行语句?

考虑以下函数。我是用C#写的。

public void Test()
{
    statement1;
    try
    {
        statement2;
    }
    catch (Exception)
    {
        //Exception caught
    }
}
Run Code Online (Sandbox Code Playgroud)

statement1我只想在没有引起异常的情况下执行statement2。是否可以statement1只在statement2 不抛出任何异常的情况下执行?

.net c# exception try-catch

1
推荐指数
1
解决办法
773
查看次数

标签 统计

.net ×1

c# ×1

exception ×1

try-catch ×1