Get Started with .NET: Your First "Hello, World!" Application
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.
Before you begin, ensure you have the latest .NET SDK installed. You can download it from the official dotnet.microsoft.com/download.
Open your terminal or command prompt and create a new directory for your project:
Navigate to the directory where you want to create your project.
mkdir HelloWorldApp
cd HelloWorldApp
Use the .NET CLI (Command Line Interface) to create a new console application. This command generates the necessary project files.
Run the following command in your terminal:
dotnet new console
This command creates a HelloWorldApp.csproj
file and a Program.cs
file.
Open the Program.cs
file in your favorite text editor or IDE. You'll see the following code:
// 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.
Now, let's run your application from the terminal. Make sure you are still in the HelloWorldApp
directory.
Execute the following command:
dotnet run
You should see the following output in your terminal:
Hello, World!
You've successfully created and run your first .NET console application. This is the foundation for building more complex and sophisticated applications.