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

24.3. The /define compiler option and #undef

Instead of defining a symbol using the #define directive, you can define symbols by passing them in as compiler options. [3] If you are using csc.exe, you can pass in defined symbols like this:

[3] This is extremely useful. You would not want to keep commenting and uncommenting your #define directives, although they are usually conveniently located near the top of the source file.

c:\expt>csc /define:DEBUG,SHOW_ON_CONSOLE test.cs

You can use the short form /d: instead of /define:. Symbols to be defined are separated by commas (with no spaces between). Remember that symbols are case sensitive. If your #if directives are expecting the DEBUG symbol, passing in debug (lower case) via the /define option ...

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