The line number and class name of the method entry are taken
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace (1, true);
int A= St. GetFrame (0). Getfilelinenumber ();
string filename = St. GetFrame (0). GetFileName ();
Take the line number and class name of the current call
int line = new System.Diagnostics.StackTrace (new System.Diagnostics.StackFrame (true)). GetFrame (0). Getfilelinenumber ();
String Filename=new System.Diagnostics.StackTrace (new System.Diagnostics.StackFrame (true)). GetFrame (0). GetFileName ();
Or
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace (new System.Diagnostics.StackFrame (true));
System.Diagnostics.StackFrame SF = St. GetFrame (0);
String line = SF. Getfilelinenumber (). ToString ();
line = SF. GetFileName ();
. NET fetching the line number and class name of the current code