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