C#

A modern, object-oriented language by Microsoft for building Windows applications, games, and cloud services.

Object-Oriented
Functional
Event-Driven
Intermediate
2000
Anders Hejlsberg (Microsoft)

Overview

C# is a modern, general-purpose programming language developed by Microsoft as part of the .NET platform. It combines the power of C++ with the simplicity of Visual Basic. C# supports strong typing, lexical scoping, and garbage collection. With each release, it continues to add features like pattern matching, records, and top-level statements that keep it modern and expressive.

Key Features

  • Modern syntax — Records, pattern matching, nullable reference types
  • .NET ecosystem — Access to the entire .NET class library
  • LINQ — Language-integrated query for collections and databases
  • Async/await — First-class asynchronous programming support
  • Cross-platform — .NET (Core) runs on Windows, Linux, macOS

Code Example

csharp
public record Point(double X, double Y);

public static string Classify(Point point) => point switch
{
    { X: 0, Y: 0 } => "Origin",
    { X: var x, Y: 0 } => $"On X-axis at {x}",
    { X: 0, Y: var y } => $"On Y-axis at {y}",
    _ => $"Point({point.X}, {point.Y})"
};

Learning Resources

Learning Path

20 topics across 5 sections

1Basics

C# fundamentals and the .NET platform.

  • Introduction to C# — .NET platform, CLI, and the C# compilation model
  • Variables & Types — Value types vs reference types, var, and nullable types
  • Control Flow — if/else, switch expressions, for, foreach, while
  • Methods — Parameters (ref, out, in), overloading, and expression-bodied members
  • Strings — Interpolation, verbatim strings, Span<char>, and StringBuilder

2OOP

Object-oriented programming in C#.

  • Classes & Structs — Properties, constructors, destructors, and init-only setters
  • Inheritance & Interfaces — sealed, abstract, virtual, interface default methods
  • Generics — Generic classes, methods, constraints, and covariance/contravariance
  • Records — Immutable reference types with value equality (C# 9+)
  • Pattern Matching — is, switch expressions, property patterns, and relational patterns

3LINQ & Collections

Language-integrated queries and data processing.

  • LINQ Basics — from/where/select, method syntax, and deferred execution
  • LINQ Operations — GroupBy, Join, Aggregate, OrderBy, and custom operators
  • Collections — List<T>, Dictionary<TK,TV>, HashSet<T>, and concurrent collections

4Async Programming

Asynchronous patterns in C#.

  • async/await — Task, Task<T>, ValueTask, and async method patterns
  • Parallel Programming — Parallel.ForEach, PLINQ, and data parallelism
  • Channels — Producer-consumer with System.Threading.Channels

5Modern C#

Latest features in C# 10-12.