C# Tutorial · C# Basics · Lesson 2 of 22

C# Get Started

Install the .NET SDK, create a console app and run it.

Install the .NET SDK

Download the .NET SDK (8 or later) from dot.net, then check:

dotnet --version

Create and run a console app

dotnet new console -o HelloApp
cd HelloApp
dotnet run

dotnet new console creates HelloApp.csproj (the project file) and Program.cs. Replace Program.cs with:

Example 1
Console.WriteLine("What's your name? (pretend we typed Ada)");
string name = "Ada";
Console.WriteLine($"Welcome to C#, {name}!");

Output

What's your name? (pretend we typed Ada)
Welcome to C#, Ada!

Run this on your computer — see “Get Started” for setup.

Editors

Visual Studio (Windows), JetBrains Rider, or VS Code with the C# Dev Kit extension all give you IntelliSense, debugging and refactoring.

Test yourself

Which command creates a new console project?

  1. dotnet create app
  2. dotnet new console
  3. csharp init
  4. dotnet init
Show answer

Answer: dotnet new console