How to use #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  w  w  w  .ja  va  2s.  co m*/

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

}

The code above generates the following result.





















Home »
  C# Tutorial »
    Custom Types »




C# Class
C# Struct
C# Interface
C# Inheritance
C# Namespace
C# Object
C# Delegate
C# Lambda
C# Event
C# Enum
C# Attribute
C# Generics
C# Preprocessor