Conditional compilation for .NET 4 [duplicate]

你说的曾经没有我的故事 提交于 2019-12-05 02:19:39
Hans Passant

The compiler isn't aware of any particular .NET Framework version. All it sees is the reference assemblies. Nor is there any guarantee that your program will run with the .NET version that you target. It is quite possible to run with the .NET 4.0 CLR even if you built for 2.0.

Use Environment.Version instead.

Chingiz Musayev

I think this is what you are looking for:

#if NET40   
...  
#elif NET35  
...  
#else NET20  
...  
#endif  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!