首页 > 解决方案 > C#中抛出异常后如何继续执行代码?

问题描述

抛出异常后如何更改此代码以继续执行应用程序?

if (str is null || str == string.Empty)
{
    throw new Exception("Wrong str");
}

标签: c#exception

解决方案


                    try
                    {
                        if (str is null || str == string.Empty)
                        {
                            throw new Exception("Wrong str");
                        }
                    }
                    catch (Exception strException)
                    {
                        Console.WriteLine(strException.Message);
                    }

                    //Continue......

推荐阅读