C# #line directive

In this chapter you will learn:

  1. How to use #line directive
  2. Syntax for #line directive
  3. Example for #line directive

#line directive

The #line directive sets the line number and filename. #line is primarily used for debugging and special applications. The number and the name are used when outputing errors or warnings.

Syntax

The general form for #line is

#line number "filename"
  • number is any positive integer
  • The optional "filename" is any valid file identifier

Example

Example for #line directive


using System;/*from   ww w  . jav  a 2 s .  co  m*/

class MainClass
{
  [STAThread]
  static void Main(string[] args)
  {
       #line default
       #line 3000
  }

}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. How to use #region directive
  2. Syntax for #region directive
  3. Example for #region directive
Home »
  C# Tutorial »
    C# Types »
      C# Preprocessor
C# preprocessor
C# #define Preprocessor
C# #if Preprocessing Directive
C# #elif Preprocessing Directive
C# #undef
C# #line directive
C# #region directive
C# #warning preprocessor