假設(shè)我只想在使用調(diào)試模式時拋出異常,我做了:try{ throw new Exception("test)";}catch(Exception ex){#if DEBUG throw;#elseConsole.WriteLine("exception => " + ex.Message);#endif}這僅適用于throw,在我得到的其他條件下:變量 ex 已聲明但從未使用
1 回答

阿晨1998
TA貢獻(xiàn)2037條經(jīng)驗 獲得超6個贊
#if DEBUG
catch(Exception)
{
throw;
}
#else
catch(Exception ex)
{
Console.WriteLine("exception => " + ex.Message);
}
#endif
- 1 回答
- 0 關(guān)注
- 157 瀏覽
添加回答
舉報
0/150
提交
取消