在c#中如何获取程序所需的.NET Framework版本

如何查看程序需要的.NET Framework版本

object[] list = System.Reflection.Assembly.GetExecutingAssembly( ).GetCustomAttributes( true );
var attribute = list.OfType<System.Runtime.Versioning.TargetFrameworkAttribute>( ).First( ); // requires Linq
string frameworkname = attribute.FrameworkName;
string frameworkdisplayname = attribute.FrameworkDisplayName;
日期:2020-04-11 22:50:22 来源:oir作者:oir