My source code needs to support both .NET version 1.1 and 2.0 … how do I test for the different versions & what is the best way to deal with this situation.
I’m wondering if I should have the two sections of code inline, in separate classes, methods etc. What do you think?
If you want to do something like this you will need to use preprocessor commands and conditional compilation symbols.
I would use symbols that clearly indicate the version of .NET you are targeting (say NET11 and NET20) and then wrap the relevant code like this:
The reason for doing it this way rather than a simple if/else is an extra layer of protection in case someone forgets to define the symbol.
That being said, you should really drill down to the heart of the reason why you want/need to do this.