title: How to get the .NET framework version that the application is using
body: <p>I have referred to the Stack Overflow question <em><a href="https://stackoverflow.com/questions/951856">Is there an easy way to check the .NET Framework version?</a></em>. But the suggestions given there did not work for the following purpose.</p>
  
  <p>How can we identify the .NET version that the C# console application is using?</p>
  
  <p><strong>Environment:</strong></p>
  
  <ul>
  <li>Visual Studio 2010</li>
  <li>.NET Framework: 3.5 (please see attached screenshot)</li>
  </ul>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>using System;
  using System.Globalization;
  using Microsoft.Win32;
  namespace TESTConsoleApplication
  {
      class Program
      {
          static void Main(string[] args)
          {
              //.NET version: Approach 1
              RegistryKey installed_versions = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP");
              string[] version_names = installed_versions.GetSubKeyNames();
              double latestFramework = Convert.ToDouble(version_names[version_names.Length - 1].Remove(0, 1), CultureInfo.InvariantCulture);
              int SP = Convert.ToInt32(installed_versions.OpenSubKey(version_names[version_names.Length - 1]).GetValue("SP", 0));
              Console.WriteLine(latestFramework);
  
              //Approach 2
              string versionval = Environment.Version.ToString();
              Console.WriteLine(versionval);
  
              //Approach 3
              string systemVersionVal = System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().ToString();
              Console.WriteLine(systemVersionVal);
  
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <p><img src="https://i.stack.imgur.com/wwUpj.jpg" alt="Enter image description here"></p>
  
  <p><strong>VERSION Setup</strong></p>
  
  <p><img src="https://i.stack.imgur.com/fq75l.jpg" alt="Enter image description here"></p>