C# Get Started
Before you can write real C# programs, you need a place to write and run your code. In this lesson you will learn what tools you need to get started, how a basic program is organized, and how to run your very first program.
Setting up your tools
To write and run C# code on your own computer, you need the .NET SDK (Software Development Kit). The SDK includes the compiler that turns your C# code into a program the computer can run, plus everything else you need to build applications.
- Download and install the free .NET SDK from the official Microsoft website.
- Install a code editor such as Visual Studio Code or the full Visual Studio.
- Open a terminal to run commands like dotnet run.
- Or simply use an online C# editor to practice without installing anything.
Your first program
Once your tools are ready, create a file with a .cs extension, for example Program.cs, and type the code below. This is the classic starting point for learning any language: a program that greets the world.
Program.cs
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello World!");
}
}When you run this program, it prints the text Hello World! and then finishes. Running it from a terminal is usually done with the dotnet run command inside your project folder.
Understanding the parts
Printing more than one line
using System;
class Program
{
static void Main()
{
Console.WriteLine("Setup complete.");
Console.WriteLine("Ready to code in C#!");
}
}Exercise: C# Get Started
What is the conventional entry point method of a C# console app?