.NET Documentation

Get Started with .NET: Your First "Hello, World!" Application

Create Your First .NET Application: "Hello, World!"

Welcome to the world of .NET! This guide will walk you through creating a simple "Hello, World!" console application, your first step into building powerful applications with .NET.

Prerequisites

Before you begin, ensure you have the latest .NET SDK installed. You can download it from the official dotnet.microsoft.com/download.

Step 1: Create a Project Directory

Open your terminal or command prompt and create a new directory for your project:

1

Navigate to the directory where you want to create your project.

mkdir HelloWorldApp
cd HelloWorldApp

Step 2: Create a New Console Application

Use the .NET CLI (Command Line Interface) to create a new console application. This command generates the necessary project files.

2

Run the following command in your terminal:

dotnet new console

This command creates a HelloWorldApp.csproj file and a Program.cs file.

Step 3: Examine the Code

Open the Program.cs file in your favorite text editor or IDE. You'll see the following code:

3
// Program.cs using System; namespace HelloWorldApp { class Program { static void Main(string[] args) { Console.WriteLine("Hello, World!"); } } }

This simple program uses the Console.WriteLine method to print the text "Hello, World!" to the console.

Step 4: Run Your Application

Now, let's run your application from the terminal. Make sure you are still in the HelloWorldApp directory.

4

Execute the following command:

dotnet run

You should see the following output in your terminal:

5
Hello, World!

Congratulations!

You've successfully created and run your first .NET console application. This is the foundation for building more complex and sophisticated applications.

Next Steps