Hello, welcome all of you to the third experience with us for vs code for beginners. If we take a review of the last two articles, there we have discussed about the basic information about the VS code and how to download and install Vs code to the Windows Operating System.
By this article, we are going to keep another leap forward. Here we are going to discuss how to make a C# console application.
So now let’s get started.
Before making the C# console application, actually, we have to install the C# extension. All the extensions that provide by VS Code are included in the extension option. So go to the extensions (Ctrl + Shift +X) at the side-bar and search for C# extension.
After installing, enable the extension and it will restart VS Code. Now we have installed C# to our VS Code.
Now that task is complete. And then, go to your desktop and create a new file “Hello World”.
Okay! guys now again go to the VS Code. There at the side-bar you can see the explorer. Go to explorer.
Select “open folder” and then open the “Hello World” file you created. You can see, your “Hello World” file gets open at the explorer.
Open up Terminal by heading (Ctrl + ~). This will provide the path to the command prompt. Now let’s initialize the C# project by typing “dotnet new”.
In other words, this means the starting of a new project. This led to create some files in the folder. You can observe those newly generated files at the explorer window when you press enter. After that again type “dotnet restore”. It’s going to fix all the links and rebuilt your project. Press enter.
From the newly generated files at the left side select the program.cs file. It is the main file of your program. When you select it program.cs file gets opened and you’ll see some codes. Those codes are auto generated codes.
Finally get into the console, type “dotnet run” and enter.
There you can identify your “hello world” output appears at the console.
If you want to add something add the code and run it.
Ex :- Console.Writeline(“How are you ?”);
This makes the output, Hello World
How are you?
Awesome, now you know how to run a basic hello world c# console application with the aid of VS Code.
“The journey of a thousand miles begins with one step.” So stay with us still this is just the beginning of a long journey.