What is the difference between the 3 catch block variants in C# ( 'Catch', 'Catch (Exception)', and 'Catch(Exception e)' )?

前端 未结 7 919
无人共我
无人共我 2021-02-02 11:36

In C#, what is the difference Between \'Catch\', \'Catch (Exception)\', and \'Catch(Exception e)\' ?

The MSDN article on try-catch uses 2 of them in its examples, but do

7条回答
  •  既然无缘
    2021-02-02 12:14

    First version catches all exceptions deriving from the Exception class.

    The second version catches specified exception.

    The third version catches a specified exception with a declared name. Then in the catch block you can use this object, for example, to see the complete error: e.ToString();

    Read more here.

提交回复
热议问题