public static void Main()
Console.WriteLine("If we do a simple throw, the stacktrace should show the nitty-gritty details:\n");
new PreserveStack().Do();
Console.WriteLine(ex.StackTrace);
Console.WriteLine("\nIf we do an also-simple throw ex, the stacktrace is reset:\n");
Console.WriteLine(ex.StackTrace);
public class PreserveStack
return new ImportantClass().DoSomething();
return new ImportantClass().DoSomething();
public class ImportantClass
public string DoSomething()
return new LessImportantButJustAsSpecial().DoSomething();
public class LessImportantButJustAsSpecial
public string DoSomething()
return new NowWereInTheWeeds().DoSomething();
public class NowWereInTheWeeds
public string DoSomething()
throw new ArgumentException("What does I did?? There are so many weeds down here!");