Because C# doesn’t use define directives like other platforms you don’t get the same compile time options based on platform target etc. The simple solution is to set a “Conditional compilation symbol” as follows
In Project properties > Build
Select the platform you want to detect . In “Conditional compilation symbols”, add a new symbol name, e.g. “MY_SPECIAL_SYMBOL”, separating it from any others already there with a “;” is necessary.
Now select the alternative configuration “Debug / Release” and add it again.
Now you have a symbol you can use in code that will only be defined when that Platform is selected.
Then in code you can use:
#if MY_SPECIAL_SYMBOL
#endif
#if !MY_SPECIAL_SYMBOL
#endif
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.