2016-04-11 8 views

Antwort

1

Try thi s eins,

try 
{ 
    doSomething() 
} 
catch (AmbiguousMatchException) 
{ 
    doSomethingElse() 
} 
2

Wenn Sie nicht die Ausnahme Details nicht benutzen wollen, können Sie den Versuch wie folgt verwenden:

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(); 
} 

Oder haben Sie die Variable für etwas zu verwenden, wie folgt aus:

try 
{ 
    doSomething(); 
} 
catch (AmbiguousMatchException MyException) 
{ 
    WriteToLog(MyException.ToString()); 
    // doSomethingElse(); 
} 

wo WriteToLog Methode wird als wie folgt definiert werden:

public static void WriteToLog(string exceptionDetails) { 
    // write the details to a file/DB 
} 
Verwandte Themen