Pre-Processor Conditional Directives
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| CSharp-Online.NET:Tutorials |
| C# Tutorials |
C# Preprocessor Directives
|
| edit |
[edit]
Basic Usage
The most often used of directives are:-
-
#define -
#if -
#endif
-
The #define directive allows you to define a pre-processor variable, this is pretty useless on its own, but used in conjunction with the #if and #endif directives it allows you to compile code depending on if a variable has been defined. Visual studio greys out code that will not be compiled.
[edit]
Example 1
[edit]
Example 2
Notice the grey line of code on line 14; this will not be executed as it is not compiled

