我有一个例外相关的问题尝试,catch异常相关的问题
我有A类,B类 当我打电话从A类B类的一些方法,放在对与尝试捕捉最后一块 那么在A类的try块中出现异常时会发生什么情况,然后在调用B类mehod后的那些接下来的步骤中,也会出现异常, 但它显示最近的异常 我的意思是覆盖第一个异常B类方法m2()。 而我仍然没有意识到首先出现的实际异常。
Class A
{
try{
B b=new B();
b.m1();
b.m2();
}
catch(Exception ex) // in catch block here what happens it display the b.m2() exception not the
b.m1() exception, while i was thinking it should display first exception
when it is calld at m1(); Why so ?
{
throw;
}
finally{}
}
class B
{
try
{
m1(){}; //here comes exception
m2(){}; // it also throw some exception
}
catch(Exception ex)
{
throw;
}
finally
{
}
}
这是什么语言?你应该添加一个标签来表明语言。此外,你应该适当地缩进代码。 – 2011-03-03 10:15:40
它的'asp.net,我发布了一段时间后编辑部分更多的代码。 – NoviceToDotNet 2011-03-03 10:23:06