Creating a Hello World application with C# and .NET Core in VS Code

Microsoft .Net core is a free, cross platform, fast, lightweight open-source managed framework for building applications and services that can be run/published on Windows, Linux and Mac operating systems.

You can use either Visual studio Code or Visual Studio. .NET Core 1.0 was released along with Visual Studio 2015 Update 3, which enables .NET Core development. .NET Core 2.0 was released along with Visual Studio 2017 15.3, ASP.NET Core 2.0, and Entity Framework Core 2.0.

On here We will use Visual Studio code.

1. So first install Visual studio code on your machine if you haven’t. You can download Visual Studion code from here:

Install Visual Studio Code

2.
And then install .NET Core.

3. After successfully installed .Net core, open VS code and install C# extension from the VS Code Marketplace. See How to install C# extension in visual studio.

Create your ‘Hello world’ console application

Open a new command prompt and run the following commands.


>dotnet new console -o DotNetCoreExample-1
>cd DotNetCoreExample-1

The dotnet command will create a new console application. The -o parameter will create a directory named myApp where your app will be stored, and populates it with the required files. The cd DotNetCoreExample-1 command puts you into the newly created app directory.

You can also open an existing folder where you want to create your console application. Just click on the Explorer icon on the left menu and then click Open Folder. Select File > Open Folder from the main menu to open the folder. After open folder run the dotnet new console command without any argument.


>dotnet new console

now you can see DotNetCoreExample-1 directory with all files in the VS code’s explorer. Open Program.cs file which already contains the necessary code to write “Hello World!” to the Console.

Run your app

In your command prompt, run the following command:

> dotnet DotNetCoreExample-1

run c# .net core console application in vs code.
run c# .net core console application in vs code.

you’ve built and run your first .NET app!