Here’s just a few notes on preprocessor directives.
They’re never terminated by a semi-colon.
They can never be translated to any commands in code
They affect the compilation process
They can prevent compilation of positions of source code. This is great for having 2 release versions of your application. It’s also great for eliminating debug information source code.
# define identifier
This directive tells the compiler that the identifier or symbol exists. It does not define a valid you for that identifier. These symbols work as a true or false designator.
# undef identifier
This directive tells the compiler that the identifier or symbol should cease the existing. Any test for the identifier will result in a false reading.
In either case nothing will happen if the symbol does or does not exist.
#if Identifier
//some code
#endif
This directive combination tells the compiler to conditionally execute the code block between the directives based on the return of the identifier. If the identifier has been defined using the #define directive, the code will execute. If it has not been defined or has been undefined using the #undef directive the code will not execute.
#elif
This directive acts the same way as and else if statement. It fits in with the #if and the #endif directives.
#if Identifier
//some code
#elif otherIdentifier
//some code
#endif
C# Allows you to use comparison operators like && and = =.
#warning #error
These directives cause warning or error messages when the compiler encounters them. The error directive will display any text to the user as if it were a compile error and then stops compilation whereas the warning directive will continue compiling the application.
#region
#endregion
These directives work in conjunction with each other to organize the layout of your code. They don’t affect compilation.
#line
This directive will alter the file name and line number information to output by compiler warnings and error messages. This is most useful when coding in conjunction with some other assembly that might alter the code you type in before sending the line number to the compiler and the line numbers may not match up correctly.
#pragma
This directive will suppress or restore compiler warnings. It can be implemented on class or method levels.