title: How to make the program detect .Net version and then enable/disable functions supported by different .Net version?
body: <p>I'm working on an old project. It was built by others long time ago, and it was built on .Net 2.0. Now, I need to add a new feature to it. However, coding wise, the new feature is supported by API/Class based on .Net 4.0. Obviously, it has to reference some new dll based on .Net 4. So, I made 2 versions of the program. One is for .Net 2.0 which does not have the new feature, and the other is .Net 4.0.</p>
  
  <p>Now, the project manager asked: is it possible to make these 2 versions into ONE version? so in the code, it detects the .Net version, and then decides whether enable/disable the new feature.</p>
  
  <p>If the user had .Net 4.0 installed, this should not be a problem. HOWEVER, there are some users, they are still using old windows servers which only have .Net 2.0 installed, and because of their work, install .Net 4.0 and reboot the system will be a problem. So, basically, this means the program has to be able to run on .Net 2.0.</p>
  
  <p>Is this possible? How to do it? Any suggestions?</p>
  
  <p>Thanks</p>
  
  <p>****** add more info</p>
  
  <p>I can detect .Net version. but I want to know how to do this:</p>
  
  <p>If on the user's system, it is .net 2.0, run the code supported by .net 2.0 only; if the user's system is .net 4.0, run the code supported by .net 4.0.</p>
  
  <p>Thanks</p>