O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

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

Chapter 24. C# preprocessor directives

If you have ever read C/C++ codes before, you can't have missed those strange looking #define and #include statements found at the beginning of the source codes. These special keywords, which begin with a # sign, are called preprocessor directives.

Preprocessor directives, though part of the source codes, are not compiled into IL codes. They are only used by the C# compiler for making certain decisions during compilation. This will become clear as you go through the examples which follow.

Table 24.1 shows the preprocessor directives supported in C#: [1]

[1] C/C++ developers: there have been significant changes to the C/C++ preprocessor directives in C#. Notice that #include is no longer a valid directive ...

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