- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do we use a #line directive in C#?
It lets you modify the compiler's line number and (optionally) the file name output for errors and warnings.
Let us see some examples.
#line 100 "demo" int a; // CS0168 on line 100 int b; // CS0168 on line 101 int c; // CS0168 on line 102
As shown above the example reports three warnings associated with line numbers. The #line 100 directive forces the line number to be 100 and until the next #line directive, the filename will be reported as "demo”.
Let’s see another example: The default directive returns the line numbering to its default numbering. This directive then counts the lines that were renumbered by the previous directive.
#line default char a; // CS0168 on line 15 float b; // CS0168 on line 16
Advertisements