开发者

Stack call in Exception Handling

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 he开发者_如何学Card 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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜