views:

448

answers:

1

Is this code:

System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
stackFrame.GetFileName();
stackFrame.GetFileLineNumber();

better for debugging compared to using a System.Diagnostics.StackTrace

+2  A: 

StackTrace uses StackFrame internally, the default constructor will take care of this for you and also set the column number.

I would stick to using StackTrace unless you need a limited amount of frames or a cut-down stack trace (perhaps for performance reasons)

Sam Saffron