Conditional compilation depending on the framework version in C#

I don’t think there are any predefined ‘preprocessor’ symbols. However you can achieve what you want like this:

  1. Create different configurations of your project, one for every version of CLR you want to support.

  2. Choose a symbol like VERSION2, VERSION3 etc. per CLR version.

  3. In every configuration, define the one symbol associated with it and undefine all others.

  4. Use these symbols in conditional compilation blocks.

Leave a Comment