Suppress warning on unused exception variable in C#

Solution 1:

Define the catch clause without the exception variable as follows:

try {
    someMethod();
} catch (XYZException) {
    // do something without using e
}

Solution 2:

Define the catch clause without the exception variable as follows:

try {
    someMethod();
} catch (XYZException) {
    // do not state e in catch clause
}

Solution 3:

Another option is to use

     try 
     {
          someMethod();
     } 
 #pragma warning disable 0168
     catch (XYZException e)
 #pragma warning restore 0168
     {
         // do not state e in catch clause
     }

This is useful in visual studio 2015 because it doesn't have a way to see the exception by default when debugging with a breakpoint on the catch.