Create your first C# Code in Visual Studio

Create a console application in Visual Studio that displays "Hello World".

Hello World 👋

Go here to see how to install Visual Studio 👉 how to install VS

In this example, we’ll create a C# Console application in Visual Studio.

Open Visual Studio 2022, on the start up page select “Create New Project”:

create new

Select “Console App” from the menu on the right, then click “Next”:

new console

Configure your project on the window that follows by providing the:

  • Project Name - This will be the name of your C# Project. All C# codes are in a C# Project.
  • Path or folder location where your C# Project will be stored
  • Solution Name - This will be the name of the Solution. In Visual Studio, all C# projects are inside a C# Solution. Solutions are containers of one or more projects. Typically, a solution contains projects related to each other.

Then click “Next”

configure project

In the next window, select the .NET framework version your project will use then click “Create”.

In this case I’ll chose 6.0 and will tick the checkbox so my project will not use ‘top-level’ statements. (find out more about top-level statements here – Top-level statements - programs without Main methods)

framework selection

Visual Studio will then create your C# Project based on a console application template. By default the template contains “Hello World” C# codes.

program dot cs

Try executing the code by “running” it. Click the green play icon in the toolbar.

running

The output will then show which is a “Hello World!" displayed in the console…

output