O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Primer to Preprocessing Directives

Use the Visual Studio feature to comment out blocks of code while evolving the code at development time. If you find yourself doing this quite often (for example, to enable or disable some diagnostic code), you’re likely better off with conditional compilation using an #if preprocessing directive. We won’t detail the preprocessing capabilities (which is really a misnomer in the world of C# because there’s no separate preprocessor stage in compilation) right now, but here’s the crux of it.

Using the #define directive, a symbol can be defined for further use in conditional preprocessing directives like #if. Blocks of code surrounded by #if and #endif are conditionally included in the source code analyzed by ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required