Search code examples
c#visual-studiocustom-configuration

Several custom configuration in #if directive


I need the following logic

#if (DEV || QA || RELEASE)
//add when dev or qa or release configuration
#endif

Is it possible in c#?


Solution

  • Yes. Quoting the #if documentation on MSDN:

    You can use the operators && (and), || (or), and ! (not) to evaluate whether multiple symbols have been defined. You can also group symbols and operators with parentheses.