Preprocessor - Overview


A number of preprocessor directives are defined and these directives affect the way program source is compiled. The preprocessor directives are similar to the preprocessor of C++. In C#, the preprocessor is for the most part unused; although, it was a critical part of the C++ compiler. The preprocessor directives used to be handled by a separate compilation phase; although, C# does not require a separate preprocessing phase. The term preprocessor directive has stuck because of historical considerations. The table below lists the C# preprocessor directives.

#define #elif #else #endif
#endregion #error #if #line
#pragma #region #undef #warning

All preprocessor directives begin with a # sign and each must be placed on its own line.