#if statements are processed before compilation, and long before your
code is actually run (which is when you will get to find out which
version of the CLR is present).
It is possible to check CLR version at runtime using
System.Environment.Version, and you could possibly use this to
conditionally select code at runtime. Something like
(untested)
ISettings settings;
if (Environment.Version.Major >= 2)
settings = (ISettings) new SettingsV2(); //access settings through
ConfigurationManager
else
settings = (ISettings) new SettingsV1(); //access settings through
ConfigurationSettings
settings.doSomething();
|