Friday, February 1, 2008

Debugger variable $exception

If your catch block do nothing with caught exception you may declare block argument without name (to avoid warning message "CS0168: The variable 'ex' is declared but never used"):

try

    {

        ...

    }

catch (Exception)

    {

// deliberately suppressing all exceptions

    }

But one day during debugging you may actually want to examine Exception. Since you don't have variable where exception is stored you can use debugger variable $exception provided by the Visual Studio.NET 2005 Debugger to examine the exception in a catch block. Just add it to Watch Window.

 

Source

No comments:

Post a Comment