public delegate void FunctionThatThrowsException();
public static void Main()
Console.WriteLine("-----------------");
RunAndLogCatchedException(ThrowException);
Console.WriteLine("-----------------");
RunAndLogCatchedException(TryCatchThrowException);
public static void ThrowException() {
throw new Exception("Exception thrown at ThrowException (line 16). The stack below correctly says that it was thrown at line 16.");
public static void TryCatchThrowException() {
throw new Exception("Exception thrown at TryCatchThrowException (line 22), but the stack below says it was thrown at line 26 because it was rethrown in the CATCH block.");
public static void RunAndLogCatchedException(FunctionThatThrowsException func) {
Console.WriteLine(ex.ToString());