Conditional compilation depending on the framework version in C#

前端 未结 5 1360
無奈伤痛
無奈伤痛 2020-11-27 06:08

Are there any preprocessor symbols which allow something like

#if CLR_AT_LEAST_3.5
// use ReaderWriterLockSlim
#else
// use ReaderWriterLock
#endif
         


        
5条回答
  •  Happy的楠姐
    2020-11-27 06:49

    If that's all you needed to do, I suppose you could use Environment.Version, but like divo's solution, it does seem to leave a lot of unneccessary code there.

提交回复
热议问题