I need to clear this warning :
try
{
// doSomething();
}
catch (AmbiguousMatchException MyException)
{
// doSomethingElse();
}
The compiler is telling me : The variable 'My Exception' is declared but never used
How can I fix this.
I need to clear this warning :
try
{
// doSomething();
}
catch (AmbiguousMatchException MyException)
{
// doSomethingElse();
}
The compiler is telling me : The variable 'My Exception' is declared but never used
How can I fix this.
Try this one,
try
{
doSomething()
}
catch (AmbiguousMatchException)
{
doSomethingElse()
}
If you are not going to use the exception details, you can use the try like this:
try
{
doSomething();
}
catch // all types of exceptions will caught here
// if you need to deal with particular type of exceptions then specify them like
// catch (AmbiguousMatchException)
{
doSomethingElse();
}
Or else you have to use the variable for something like the following:
try
{
doSomething();
}
catch (AmbiguousMatchException MyException)
{
WriteToLog(MyException.ToString());
// doSomethingElse();
}
where WriteToLog
method will be defined as like the following:
public static void WriteToLog(string exceptionDetails) {
// write the details to a file/DB
}