try { Process(currentLocation); Console.WriteLine("Done processing"); } catch (ArgumentException e) { // handle the exception here } catch (Exception e) { // handle the more general exception here } 当使用了多个catch语句时,导出类型必须列在它的任何基类之前。这有助于提高可读性。你可以更早地判定出运行时(Runtime)的行为。
System.Exception: Exception in Test1 ---> System.Exception: Exception in Test2 ---> System.DivideByZeroException: Attempted to divide by zero. 假如你在编译时使用了/debug开关,这样的输出将使大大方便调试。你还可以得到每一级的文件名和行号。