C# is a statically typed language created by Microsoft and is widely used in games (Unity), web (ASP.NET), desktop, and mobile. In this section, you will install the .NET 8 SDK, create a console project, and run it directly.
Learning Objectives
- Know the meaning of .NET 8 LTS and the difference between SDK/Runtime
- Choose one of the IDEs (Visual Studio / VS Code / Rider) and install it.
- Create your first project with
dotnet new console - Run with
dotnet runand check the results. - Perform simple input/output with
Console.WriteLine/Console.ReadLine
Key concepts
1) What is .NET?
.NET is a bundle of runtime + standard library + SDK that runs languages such as C#, F#, and VB.NET. Code written once can be run in all On-Windows/macOS/Linux.
- .NET 8 LTS: Long Term Support version released in November 2023. Official support until November 2026.
- SDK: Compiler and tool set required for development (including
dotnetCLI) - Runtime: Minimum components required to simply run the created program.
2) Check SDK installation
After installation, check with the command below in terminal.
dotnet --version
#Example output: 8.0.xxx
If you start with 8.0, it's OK. If there is no command, download and install .NET 8 SDK from https://dotnet.microsoft.com/download.
3) Select IDE
- Visual Studio 2022 (Windows) — Heavy but most integrated environment
- VS Code + C# Dev Kit (cross platform) — Light and fast, recommended
- JetBrains Rider — Paid but powerful refactoring
This course is IDE agnostic. Either way, the operation is the same with dotnet CLI.
4) Create your first project
dotnet new console -o HelloApp
cd HelloApp
dotnet run
dotnet new console: Create console app template-o HelloApp: Created inHelloAppfolderdotnet run: Build (restoreautomatically if necessary) → Run
When running for the first time, Hello, World! is output.
5) Top-level statements
Since .NET 6, you can skip the Main method and write your code straight away.
// Program.cs
Console.WriteLine("Hello!");
Console.WriteLine outputs with line breaks, and Console.Write outputs without line breaks.
See as example
Example 1 — HelloApp/Program.cs: The most basic
//First C# program
Console.WriteLine("Hello, C# !");
Execution result
Hello, C# !
Note: Don't forget the semicolon (;). C# separates sentences with ;, not line breaks.
Example 2 — Echo/Program.cs: Accept input and say hello
Console.Write("Please enter your name:");
string? name = Console.ReadLine();
Console.WriteLine($"Hello {name}!");
Execution result
Enter your name: Jisoo
Hello, Jisoo!
Memo: Console.ReadLine() can return null if there is no input, so the type is string?. (More details in section 2)
Example 3 — MultiPrint/Program.cs: Multiple lines + string interpolation
string product = "apple";
int count = 3;
int price = 1500;
Console.WriteLine("=== Purchase History ===");
Console.WriteLine($"Product: {product}");
Console.WriteLine($"Quantity: {count}");
Console.WriteLine($"Total: {count * price} won");
Execution result
=== Purchase History ===
Product: Apples
Quantity: 3
Total: 4,500 won
Memo: { } within $"..." can be entered as an expression. This is called string interpolation.
Common Mistakes
- Case is incorrect, like
Console.Writeline— C# is case sensitive. - Missing
;at the end of the sentence — compilation error. - Using only
"{name}"without$,{name}is output as is. - When running
dotnet runoutside the project folder, a “project not found” error occurs. - Confusing
.NET Framework 4.xand.NET 8— This tutorial is based on .NET 8 (Core series).
Cleanup
- After installing .NET 8 SDK, check with
dotnet --version dotnet new console -o name→dotnet runis the basic flow.- Output as
Console.WriteLine, input asConsole.ReadLine $"..."string interpolation neatly inserts variables
Try it yourself
cd src/HelloApp
dotnet run
cd ../Echo
dotnet run
cd ../MultiPrint
dotnet run