tags:

views:

45

answers:

1

According to the design guideline the catching exception should start from more specification exception to System.Exception.

like :

try
{


}
catch(IOException IOEx)
{
}
catch(ArrayIndexOutOfRangeException AIE)
{
}
.....
catch(Exception ex)
{
}

I heard that CLR tracks the stack to trace the exception one by one to find the matching one(if an error occur). As stack is "Last in first out" in nature won't CLR look in reverse order ? ( i.e Exception .. ArrayIndexOutOfRangeException .. IOException)

+4  A: 

No - the stack in this case is the call stack, so if it doesn't find a handler in the current method, it will move up the stack to look for a handler. Within a particular method however, handlers are tested in the order they are specified.

Lee