c# two try catch code example
Example 1: c# try catch multiple catches
try
{
Console.WriteLine("Chose a number: ");
int usrNo = Convert.ToInt32(Console.ReadLine());
return usrNo;
}
catch (FormatException ex)
{
ErrorMessagePrintCustomMessage("You pressed a letter");
}
catch (Exception ex) { ErrorMessageErrorOccured(ex); }
Example 2: catch multiple exception c#
catch (Exception ex)
{
if (ex is FormatException || ex is OverflowException)
{
WebId = Guid.Empty;
return;
}
throw;
}