O'Reilly logo

Special Edition Using C# by NIIT

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Preprocessor Directives

In some programming languages, such as C++, the preprocessing stage is a separate process from compilation. This stage happens before the actual process of compilation. The following are some of the areas where preprocessing is useful:

  • Conditional compilation

  • Header files inclusion

  • Macro expansion

However, in C#, the only area where preprocessing is used for conditional inclusion and exclusion of code. Also, in C#, the compiler itself emulates the preprocessor.

A preprocessor directive is a special command that begins with the # symbol.

The preprocessor directives provided in C# are

  • #define

  • #undef

  • #if

  • #else

  • #elif

  • #endif

  • #warning

  • #error

  • #line

  • #region

  • #endregion

The following sections discuss each of these preprocessor directives in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required