.NET Framework各版本汇总以及之间的关系

时间:2025-04-03 11:48:03
using System;
using Microsoft.Win32;
 
public class GetDotNetVersion
{
     public static void Main()
     {
         ( ".NET框架版本:" );
         using (RegistryKey ndpKey = (, "" ).OpenSubKey( @"SOFTWARE\Microsoft\NET Framework Setup\NDP\" ))
         {
             foreach ( string versionKeyName in ())
             {
                 if (( "v" ))
                 {
 
                     RegistryKey versionKey = (versionKeyName);
                     string name = ( string )( "Version" , "" );
                     string sp = ( "SP" , "" ).ToString();
                     string install = ( "Install" , "" ).ToString();
                     if (install == "" ) //no install info, ust be later
                         (versionKeyName + "  " + name);
                     else
                     {
                         if (sp != "" && install == "1" )
                         {
                             (versionKeyName + "  " + name + "  SP" + sp);
                         }
                     }
                     if (name != "" )
                     {
                         continue ;
                     }
                     foreach ( string subKeyName in ())
                     {
                         RegistryKey subKey = (subKeyName);
                         name = ( string )( "Version" , "" );
                         if (name != "" )
                             sp = ( "SP" , "" ).ToString();
                         install = ( "Install" , "" ).ToString();
                         if (install == "" ) //no install info, ust be later
                             (versionKeyName + "  " + name);
                         else
                         {
                             if (sp != "" && install == "1" )
                             {
                                 ( "  " + subKeyName + "  " + name + "  SP" + sp);
                             }
                             else if (install == "1" )
                             {
                                 ( "  " + subKeyName + "  " + name);
                             }
                         }
                     }
                 }
             }
         }
 
         ();
         ( "操作系统版本:" + ());
         ( "当前.NET框架版本:" + ());
         ();
     }
}