Obtains the location and method name of the current class.
Stacktrace ST = new stacktrace (New stackframe (true); console. writeline ("stack trace for current level: {0}", St. tostring (); stackframe Sf = ST. getframe (0); console. writeline ("file: {0}", SF. getfilename (); console. writeline ("method: {0}", SF. getmethod (). name); console. writeline ("line number: {0}", SF. getfilelinenumber (); console. writeline ("column number: {0}", SF. getfilecolumnnumber ());
Example:
Stackframe Sf = new stacktrace (New stackframe (true )). getframe (0); debug. writeline (string. format ("error: method [{1 }. {2} ({0})] error: {3}; ", finalblog. ID, SF. getfilename (), SF. getmethod (). name, Ex. tostring ()));
Output:
Error: method [E: \ SNS \ social \ code \ sns_dcc \ blogoperate. cs. delsnsblogtomongo (0)] error: system. indexoutofrangeexception: The index exceeds the array limit.