Is there a way to detect the version of the compiler in code like you could with VC++ with preprocessor directives I can't find a predefined one for C# that indicates if running VS .NET, VS2003 or VS2005 We would like code to be potentially buildable under each compiler for a transition period. Manually adding these defines to projects would be a pain and would require maintaining seperate projects or build configurations, so was hoping there is a predefined one like there is for VC++.

Detect compiler version?
kayfish
It's not too hard to do this, simply:
1. Right-click on the Project in Solution Explorer and click Properties
2. In the Build tab, enter a symbol in the Conditional compilation symbols text box.
You could use NET1_1 for .NET 1.1. NET2_0 for .NET 2.0, and then do the following:
#if NET1_1
// Do something .NET 1.1 related
#elif NET2_0
// Do something .NET 2.0 related
#endif
btimur
Not sure about a way to detect the compiler in code, but you could get the runtime version in code by using:
RuntimeEnvironment.GetSystemVersion()