try { Process(currentLocation); Console.WriteLine("Done processing"); } catch (ArgumentException e) { // handle the exception here } catch (Exception e) { // handle the more general exception here } 當(dāng)使用了多個catch語句時,導(dǎo)出類型必須列在它的任何基類之前。這有助于提高可讀性。你可以更早地判定出運(yùn)行時(Runtime)的行為。
System.Exception: Exception in Test1 ---> System.Exception: Exception in Test2 ---> System.DivideByZeroException: Attempted to divide by zero. 假如你在編譯時使用了/debug開關(guān),這樣的輸出將使大大方便調(diào)試。你還可以得到每一級的文件名和行號。