# Preprocessor Directives in C#
#define | It defines a sequence of characters, called symbol. |
#undef | It allows you to undefine a symbol. |
#if | It allows testing a symbol or symbols to see if they evaluate to true. |
#else | It allows creating a compound conditional directive, along with #if. |
#elif | It allows for creating a compound conditional directive. |
#endif | Specifies the end of a conditional directive. |
#line | It lets you modify the compiler’s line number and (optionally) the file name output for errors and warnings. |
#error | It allows generating an error from a specific location in your code. |
#warning | It allows generating a level one warning from a specific location in your code. |
#region | It lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor. |
#endregion | It marks the end of a #region block. |
# The #define Preprocessor
#define symbol
# Conditional Directives
#if symbol [operator symbol]...
Where, symbol is the name of the symbol you want to test. You can also use true and false or prepend the symbol with the negation operator.
The operator symbol is the operator used for evaluating the symbol. Operators could be either of the following:
- == (equality)
- != (inequality)
- && (and)
- || (or)