Retrieving Current Line Number in Your Code
If you're working with code and want to know which line number is currently being executed, there's a solution for you.
You can accomplish this using the compiler's assistance in .NET 4.5 / C# 5. Here's how:
1 2 3 4 5 6 |
|
1 2 3 4 5 6 |
|
1 |
|
The output will display, for instance:
1 |
|
Additionally, if you need the path of the original code file, the [CallerFilePath] attribute can provide that information.
The above is the detailed content of How Can I Get the Current Line Number in My C# Code?. For more information, please follow other related articles on the PHP Chinese website!