如何确定LinqPAD对应的.net framework 目标框架版本
作者:互联网
1 void Main() 2 { 3 GetFWVersion().Dump(); 4 } 5 6 static Version _version; 7 public static Version GetFWVersion () 8 { 9 if (_version != null) return _version; 10 11 if (typeof (int).GetType ().BaseType.Name == "Type") return _version = new Version (4, 0); 12 13 using (var key = Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full")) 14 { 15 int? versionKey = key == null ? null : key.GetValue ("Release") as int?; 16 if (versionKey >= 461808) return _version = new Version (4, 7, 2); 17 if (versionKey >= 461308) return _version = new Version (4, 7, 1); 18 if (versionKey >= 460798) return _version = new Version (4, 7); 19 if (versionKey >= 394802) return _version = new Version (4, 6, 2); 20 if (versionKey >= 394254) return _version = new Version (4, 6, 1); 21 if (versionKey >= 393273) return _version = new Version (4, 6); 22 if (versionKey >= 379893) return _version = new Version (4, 5, 2); 23 if (versionKey >= 378675) return _version = new Version (4, 5, 1); 24 } 25 return _version = new Version (4, 5); 26 }
标签:versionKey,LinqPAD,return,Version,int,framework,version,new,net 来源: https://www.cnblogs.com/bisslot/p/14271396.html