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
  • 159,224
  • 26
  • 237
  • 393
IEnumerable
  • 3,430
  • 13
  • 44
  • 77
  • [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

5

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
  • 76
  • 1
  • 6