See this

Sujit Patil replied to sudhakar subramaniyan at 05-Jul-08 05:28

The try-catch statement consists of a try block followed by one or more catch clauses,

which specify handlers for different exceptions.

This statement takes one of the following forms:

try try-block 
catch (exception-declaration-1) catch-block-1 
catch (exception-declaration-2) catch-block-2 
...
try try-block catch catch-block
where: 
try-block
Contains the code segment expected to raise the exception.
exception-declaration, exception-declaration-1, exception-declaration-2
The exception object declaration.
catch-block, catch-block-1, catch-block-2
Contains the exception handler.

e.g.;

using System;

public class Example13_4
{

  public static void Main()
  {

    try
    {

      int[] myArray = new int[2];
      Console.WriteLine("Attempting to access an invalid array element");
      myArray[21;

    }
    catch (DivideByZeroException e)
    {

      // code that handles a DivideByZeroException
      Console.WriteLine("Handling a System.DivideByZeroException object");
      Console.WriteLine("Message = " + e.Message);
      Console.WriteLine("StackTrace = " + e.StackTrace);

    }
    catch (IndexOutOfRangeException e)
    {

      // code that handles an IndexOutOfRangeException
      Console.WriteLine("Handling a System.IndexOutOfRangeException object");
      Console.WriteLine("Message = " + e.Message);
      Console.WriteLine("StackTrace = " + e.StackTrace);

    }
    catch (Exception e)
    {

      // code that handles a generic Exception: all other exceptions
      Console.WriteLine("Handling a System.Exception object");
      Console.WriteLine("Message = " + e.Message);
      Console.WriteLine("StackTrace = " + e.StackTrace);

    }

  }

}


http://msdn.microsoft.com/en-us/library/0yd65esw(VS.71).aspx

Best Luck!!!!!!!!!!!!!!!!!!!
Sujit.


Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  how to use multiple try catch block - sudhakar subramaniyan  05-Jul-08 05:19 5:19:23 AM
      try this... - Vasanthakumar D  05-Jul-08 05:31 5:31:34 AM
      See this - Sujit Patil  05-Jul-08 05:28 5:28:01 AM
      Multiple Try Catch Block example - Sanjay Verma  05-Jul-08 05:35 5:35:57 AM
      Re : how to use multile try catch block. - Ashutosh Dhok  05-Jul-08 06:22 6:22:07 AM
      Re : how to use multile try catch block. - Ashutosh Dhok  05-Jul-08 06:23 6:23:07 AM
      ans - Umapathy Kaliaperumal  05-Jul-08 06:34 6:34:53 AM
      Multiple try catch or nested try catch: - Chirag Bhavsar  05-Jul-08 08:52 8:52:08 AM
      reply - alice johnson  05-Jul-08 01:17 1:17:24 PM
View Posts