DEV Community

IronSoftware
IronSoftware

Posted on

Getting Started with C# in 2025

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!");
Enter fullscreen mode Exit fullscreen mode

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:

  1. .NET SDK — The development kit
  2. Code editor — VS Code (free) or Visual Studio (free Community edition)

Install .NET SDK

Windows:

winget install Microsoft.DotNet.SDK.10
Enter fullscreen mode Exit fullscreen mode

macOS:

brew install dotnet-sdk
Enter fullscreen mode Exit fullscreen mode

Linux:

sudo apt install dotnet-sdk-10.0
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

Program.cs — Your code

Console.WriteLine("Hello, World!");
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Conditionals

if (age >= 18)
{
    Console.WriteLine("Adult");
}
else
{
    Console.WriteLine("Minor");
}

// Ternary operator
var status = age >= 18 ? "Adult" : "Minor";
Enter fullscreen mode Exit fullscreen mode

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++;
}
Enter fullscreen mode Exit fullscreen mode

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;
Enter fullscreen mode Exit fullscreen mode

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();
Enter fullscreen mode Exit fullscreen mode

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; }
}
Enter fullscreen mode Exit fullscreen mode

Objects: Instances of classes

var myCar = new Car { Make = "Toyota", Model = "Camry" };
Enter fullscreen mode Exit fullscreen mode

Inheritance: Classes can extend other classes

class ElectricCar : Car
{
    public int BatteryCapacity { get; set; }
}
Enter fullscreen mode Exit fullscreen mode

Interfaces: Contracts for behavior

interface IDriveable
{
    void Start();
    void Stop();
}
Enter fullscreen mode Exit fullscreen mode

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
};
Enter fullscreen mode Exit fullscreen mode

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();
Enter fullscreen mode Exit fullscreen mode

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");
Enter fullscreen mode Exit fullscreen mode

This is essential for web development and any I/O operations.

What Can I Build with C#?

Console applications:

dotnet new console
Enter fullscreen mode Exit fullscreen mode

Web APIs:

dotnet new webapi
Enter fullscreen mode Exit fullscreen mode

Web applications (Blazor):

dotnet new blazor
Enter fullscreen mode Exit fullscreen mode

Desktop applications (WPF/WinForms/MAUI):

dotnet new wpf
dotnet new maui
Enter fullscreen mode Exit fullscreen mode

Mobile applications (MAUI):

dotnet new maui
Enter fullscreen mode Exit fullscreen mode

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>>();
Enter fullscreen mode Exit fullscreen mode

Ignoring null:

// Will crash if name is null
Console.WriteLine(name.ToUpper());

// Safe
Console.WriteLine(name?.ToUpper() ?? "No name");
Enter fullscreen mode Exit fullscreen mode

Not using string interpolation:

// Old way
var message = "Hello, " + name + "!";

// Better
var message = $"Hello, {name}!";
Enter fullscreen mode Exit fullscreen mode

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

  1. Todo list app — Practice CRUD operations
  2. Calculator — Methods and user input
  3. Number guessing game — Loops and conditionals
  4. Contact book — Classes and collections
  5. 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)