문제

The #line processor directive in C# increases the line number for each line to the end of file or until it reaches another #line processor directive; an auto incremental line number.

That was interesting! For example:

try
{
#line 110
    act();
    throw new InvalidOperationException();
}
catch (Exception x) { Console.WriteLine(x); }

Shows that an exception happened at line 111 (Not 110!).

Question: Assume that #line shows a line number different from real line number. For example #line 110 is actually placed at real line number 13. Now is there a way to cancel the functionality of #line and show that an exception happened on actual line 23 (not 120)?

Note: I just want to be sure I am not missing anything (or doing anything stupid).

I am working with Visual Studio 2012 on a .NET 4.5 project.

도움이 되었습니까?

해결책

You're looking for #line default, which reverts back to the natural line numbering.
See the documentation

다른 팁

#line N directive set difference between real line and virtual N line. To restore real line counting use #line default.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top