📜  异常 e 为空 c# 代码示例

📅  最后修改于: 2022-03-11 14:48:42.328000             🧑  作者: Mango

代码示例1
//Bug with VS: Exception e == null
//Happens when multiple catch variables are the same
//an example of the solution:
try
{
    // do something
}
catch (WebException webEx) // using a variable named 'webEx' for this catch
{
    Logger.Log("Error while tried to do something. Error: " + webEx.Message); // <-
}
catch (Exception ex) // using a DIFFERENT variable for this one
{
    Logger.Log("Error while tried to do something. Error: " + ex.Message);
}