C# get current line number in cs file

using System.Diagnostics;

 static void Main(string[] args)
        {
            ReportError();
            ReportError();
            ReportError();
            ReportError();
            Console.ReadLine();
        }

        private static void ReportError()
        {
            StackFrame callStack = new StackFrame(1, true);
            Console.WriteLine(callStack.GetFileLineNumber());
        }
原文地址:https://www.cnblogs.com/Fred1987/p/13795130.html