LoginSignup
22
18

More than 3 years have passed since last update.

【C#】C#のバージョンと.NETのバージョンを確認する方法

Posted at

C#のバージョン確認方法

コードのどこかに#error versionを入力する

↓こんな感じで入力すると
image.png

↓こんな風に、Visual Studio の警告に出てくる
image.png

これだと私の場合はC#8.0

.NETのバージョン確認方法

System.Runtime.InteropServices をusingして
RuntimeInformation.FrameworkDescriptionを参照すれば良い

using System;
using System.Runtime.InteropServices;

class Class1
{
    static void Main(string[] args)
    {
        Console.WriteLine(RuntimeInformation.FrameworkDescription);
    }
}

結果:

.NET Core 3.1.8

参考

22
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
18