c# exception set stack trace code example Example: c# print exception stack trace System.Diagnostics.Debug.WriteLine(e.StackTrace.ToString());