C# is one of the most in-demand programming languages. It runs on Windows, macOS, Linux, mobile, and the web. Here's how to start from zero in 2025.
// Your first C# program
Console.WriteLine("Hello, World!");
One line. That's a complete program in modern C#.
Why Learn C# in 2025?
Jobs: C# consistently ranks in the top 5 most in-demand languages. Enterprise, gaming, web, mobile — all hiring.
Versatility: Build desktop apps, web APIs, mobile apps, games (Unity), cloud services, and IoT devices.
Modern language: C# evolves yearly. Version 14 shipped in November 2025 with powerful new features.
.NET is cross-platform: Same code runs on Windows, macOS, and Linux. No vendor lock-in.
What Do I Need to Install?
Just two things:
- .NET SDK — The development kit
- Code editor — VS Code (free) or Visual Studio (free Community edition)
Install .NET SDK
Windows:
winget install Microsoft.DotNet.SDK.10
macOS:
brew install dotnet-sdk
Linux:
sudo apt install dotnet-sdk-10.0
Install VS Code
Download from code.visualstudio.com
Install the C# Dev Kit extension from the Extensions marketplace.
How Do I Write My First Program?
Open a terminal and run:
mkdir MyFirstApp
cd MyFirstApp
dotnet new console
dotnet run
Output: Hello, World!
That's it. You've built and run a C# application.
What Did dotnet new console Create?
Two files:
MyFirstApp.csproj — Project configuration
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
</Project>
Program.cs — Your code
Console.WriteLine("Hello, World!");
Modern C# uses "top-level statements." No boilerplate needed.
What Are the Basic Concepts?
Variables
// Explicit type
string name = "Alice";
int age = 25;
double price = 19.99;
bool isActive = true;
// Inferred type (compiler figures it out)
var message = "Hello"; // string
var count = 42; // int
Conditionals
if (age >= 18)
{
Console.WriteLine("Adult");
}
else
{
Console.WriteLine("Minor");
}
// Ternary operator
var status = age >= 18 ? "Adult" : "Minor";
Loops
// For loop
for (int i = 0; i < 5; i++)
{
Console.WriteLine(i);
}
// Foreach loop
var names = new[] { "Alice", "Bob", "Charlie" };
foreach (var n in names)
{
Console.WriteLine(n);
}
// While loop
int counter = 0;
while (counter < 3)
{
Console.WriteLine(counter);
counter++;
}
Methods (Functions)
int Add(int a, int b)
{
return a + b;
}
var result = Add(5, 3); // 8
// Expression-bodied method
int Multiply(int a, int b) => a * b;
Classes
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public void Greet()
{
Console.WriteLine($"Hi, I'm {Name}");
}
}
var person = new Person { Name = "Alice", Age = 25 };
person.Greet();
What Is Object-Oriented Programming?
C# is an object-oriented language. Core concepts:
Classes: Blueprints for objects
class Car
{
public string Make { get; set; }
public string Model { get; set; }
}
Objects: Instances of classes
var myCar = new Car { Make = "Toyota", Model = "Camry" };
Inheritance: Classes can extend other classes
class ElectricCar : Car
{
public int BatteryCapacity { get; set; }
}
Interfaces: Contracts for behavior
interface IDriveable
{
void Start();
void Stop();
}
What Are Collections?
Store multiple items:
// Array (fixed size)
int[] numbers = [1, 2, 3, 4, 5];
// List (dynamic size)
var names = new List<string> { "Alice", "Bob" };
names.Add("Charlie");
// Dictionary (key-value pairs)
var ages = new Dictionary<string, int>
{
["Alice"] = 25,
["Bob"] = 30
};
What Is LINQ?
Language Integrated Query. Query collections with readable syntax:
var numbers = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
// Filter
var evens = numbers.Where(n => n % 2 == 0);
// Transform
var doubled = numbers.Select(n => n * 2);
// Aggregate
var sum = numbers.Sum();
var max = numbers.Max();
// Chain operations
var result = numbers
.Where(n => n > 5)
.Select(n => n * 2)
.OrderByDescending(n => n)
.ToList();
What Is Async/Await?
Handle asynchronous operations without blocking:
async Task<string> FetchDataAsync(string url)
{
using var client = new HttpClient();
return await client.GetStringAsync(url);
}
// Usage
var data = await FetchDataAsync("https://api.example.com/data");
This is essential for web development and any I/O operations.
What Can I Build with C#?
Console applications:
dotnet new console
Web APIs:
dotnet new webapi
Web applications (Blazor):
dotnet new blazor
Desktop applications (WPF/WinForms/MAUI):
dotnet new wpf
dotnet new maui
Mobile applications (MAUI):
dotnet new maui
Games (Unity):
Unity game engine uses C# for scripting.
What Should I Learn Next?
Week 1-2: Basic syntax, variables, conditionals, loops
Week 3-4: Methods, classes, object-oriented programming
Week 5-6: Collections, LINQ, file I/O
Week 7-8: Async/await, web APIs
Month 3+: Pick a specialty (web, desktop, mobile, games)
What Are Good Learning Resources?
Free:
- Microsoft Learn (learn.microsoft.com)
- C# documentation
- YouTube tutorials (Tim Corey, Nick Chapsas)
Paid:
- Pluralsight
- Udemy courses
- LinkedIn Learning
Practice:
- Exercism.io (free exercises)
- LeetCode (algorithms)
- Build your own projects
Common Beginner Mistakes
Not using var appropriately:
// Too verbose
Dictionary<string, List<int>> map = new Dictionary<string, List<int>>();
// Better
var map = new Dictionary<string, List<int>>();
Ignoring null:
// Will crash if name is null
Console.WriteLine(name.ToUpper());
// Safe
Console.WriteLine(name?.ToUpper() ?? "No name");
Not using string interpolation:
// Old way
var message = "Hello, " + name + "!";
// Better
var message = $"Hello, {name}!";
Quick Reference
| Concept | Example |
|---|---|
| Variable | var x = 10; |
| If/else | if (x > 5) { } else { } |
| For loop | for (int i = 0; i < 10; i++) { } |
| Foreach | foreach (var item in list) { } |
| Method | int Add(int a, int b) => a + b; |
| Class | class MyClass { } |
| List | var list = new List<string>(); |
| LINQ filter | list.Where(x => x > 5) |
| Async | async Task DoWork() { await Task.Delay(1000); } |
Starter Project Ideas
- Todo list app — Practice CRUD operations
- Calculator — Methods and user input
- Number guessing game — Loops and conditionals
- Contact book — Classes and collections
- Simple web API — HTTP and JSON
Start simple. Build complexity gradually.
*Written by Jacob Mellor, CTO at Iron Software. Jacob created IronPDF and leads
Top comments (0)