using System;
void MethodWithException() {
try {
throw new Exception("test exception");
}
catch (Exception e) {
//实现任意部分处理,
//并把错误传给调用方代码
Console.WriteLine(e.ToString());
throw;
}
}
try {
MethodWithException();
}
catch (Exception e) {
Console.WriteLine(e.Message);
}