Can one try statement have many catch statements

Showing Answers 1 - 13 of 13 Answers

sanjay

  • Sep 26th, 2006
 

one Try Ststement can have only one catch statement.

when ever error occurs in TRY or can catch in it's approprate catch block only.

  Was this answer useful?  Yes

kamal gupta

  • Sep 26th, 2006
 

yes one try catch have many catch statement

using System;
class MyClient
{
public static void Main()
{
try
{
  throw new DivideByZeroException("Invalid Division");
}
catch(DivideByZeroException e)
{
  Console.WriteLine("Exception" );
}

Catch(Exception ex)

{

Console.writeline(Ex.message);

}


 Console.WriteLine("LAST STATEMENT");
}
}

we can add following exception

System.OutOfMemoryException
System.NullReferenceException
System.InvalidCastException
System.ArrayTypeMismatchException
System.IndexOutOfRangeException
System.ArithmeticException
System.DevideByZeroException
System.OverFlowException

Nagender Rachakonda

  • Oct 6th, 2006
 

Yes

  Was this answer useful?  Yes

anji

  • Oct 16th, 2006
 

one try statement may contain many catch blocks

  Was this answer useful?  Yes

NagaSekhar Karanam

  • Feb 23rd, 2007
 

one try block have many catch blocks which r mutually exclusive

  Was this answer useful?  Yes

Yes, dear. Many try catch blocks can be associated with one try block, but only one catch block's code gets executed whenever there is an error in the try block. I hope it answers your question!

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions