Partager via


How to: Retrieve the .NET Framework Version (C++/CLI)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at How to: Retrieve the .NET Framework Version (C++/CLI).

The following code example demonstrates how to determine the version of the currently installed .NET Framework with the Version property, which is a pointer to a Version object that contains the version information.

Example

// dotnet_ver.cpp  
// compile with: /clr  
using namespace System;  
int main()   
{  
   Version^ version = Environment::Version;  
   if (version)  
   {  
      int build = version->Build;  
      int major = version->Major;  
      int minor = version->Minor;  
      int revision = Environment::Version->Revision;  
      Console::Write(".NET Framework version: ");  
      Console::WriteLine("{0}.{1}.{2}.{3}",   
            build, major, minor, revision);  
   }  
   return 0;  
}  

See Also

Windows Operations (C++/CLI)
.NET Programming with C++/CLI (Visual C++)