0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C#の基本的な構文を試すための環境をVisualStudioCodeで作成する

Last updated at Posted at 2020-11-01

C#の基本的な構文を試すための環境をVisualStudioCodeで作成する

参考URL

チュートリアル: Visual Studio Code を使用して .NET Core コンソール アプリケーションを作成する

対象者

  • C#の基本的な構文を試すための環境を簡単に作成したい方

実践

プロジェクトの作成

以下のコマンドを実行

> dotnet new console

以下のようなディレクトリ、ファイルが作成される。
プロジェクト名は現在のディレクトリの名前になる

C:.
│  ConsoleTest.csproj
│  Program.cs
└─obj
    ConsoleTest.csproj.nuget.dgspec.json
    ConsoleTest.csproj.nuget.g.props
    ConsoleTest.csproj.nuget.g.targets
    project.assets.json
    project.nuget.cache

Program.cs

Main はアプリケーションのエントリ ポイントで、アプリケーションを起動するときに、ランタイムによって自動的に呼び出されるメソッドです。 アプリケーションが起動されるときに提供されるコマンドライン引数はすべて args 配列にあります。

using System;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

アプリケーションの実行

以下のコマンドを実行するとProgram.csMainメソッドが実行される

> dotnet run
Hello World!

まとめ

作成されたProgram.cs内でいろいろと試せると思います。

補足

@ktz_aliasさんからコメントで別の方法を教えていただきましたので参考にさせていただきます。
dotnet/interactive

0
2
2

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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?