我有一個例外相關的問題嘗試,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