#480 – Pre-Processing Directives
December 21, 2011 Leave a comment
Pre-processing directives are elements that you can include in your source code that are not part of the source code itself. Instead, they instruct the C# compiler to perform some particular action, like skipping compilation of a section of the code.
The pre-processing directives available in C# include:
- #define/#undef – Define/undefine condition compilation symbols (see #if)
- #if/#elif/#else/#endif – Skip compilation of a section of code based on the existence of a conditional compilation symbol
- #line – specifies a line number to use when reporting errors
- #error – issue errors during compilation
- #warning – issue warnings during compilation
- #region/#endregion – define a collapsible code region, to improve readability
- #pragma warning – disable or restore certain compiler warnings
- #pragma checksum – generate a checksum for an ASP.NET page, for debugging purposes