1

How do we get the Line number of the currently executing code in C#/WinForms.

In PHP we can do __LINE__ or __FUNCTION__ to access details about the currently executing piece of code.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
IEnumerable
  • 3,610
  • 14
  • 49
  • 78
  • [this is the page](http://msdn.microsoft.com/en-us/library/hh534540.aspx) that refers to what the answer in the question Selman posted is talking about which is what your looking for. – RadioSpace Apr 01 '14 at 02:37
  • Thanks this is all very useful. Now I can provide more info and callstack data in my app :) – IEnumerable Apr 01 '14 at 02:38

1 Answers1

4

check this class and example StackFrame

StackFrame sf = st.GetFrame(i);
Console.WriteLine(" File: {0}", sf.GetFileName());
Console.WriteLine(" Line Number: {0}", sf.GetFileLineNumber());
Console.WriteLine(" Column Number: {0}", sf.GetFileColumnNumber());
JTL
  • 74
  • 1
  • 6