CodeBlanks Logo Icon CodeBlanks
Free 4 levels C#

C#

Learn modern C# 12 and .NET 8 from variables to OOP, async/await, LINQ and expert topics with hands-on projects.

The C# course covers all levels with variables, OOP, generics, LINQ, async/await, reflection, source generators and memory management. Each level ends with projects and challenges.

  • 362 lessons
  • 29 h 30 min
  • 10 projects

No account needed, you can start right away. To save your progress, create a free account

Levels

The C# course goes from zero to expert in four levels. Start at any level you like.
Not sure of your level? Take the placement test
Beginner

Learn C# and .NET fundamentals: variables, data types, loops, arrays, collections, methods and console I/O.

  • C# basics
  • Variables
  • Data types
  • Operators
116 lessons · 8 h 53 min See lessons →
Intermediate

Learn OOP, generics, collections, LINQ, file I/O and serialization in C#.

  • Classes
  • Constructor
  • Inheritance
  • Encapsulation
116 lessons · 9 h 37 min See lessons →
Advanced

Learn async/await, advanced LINQ, reflection, attributes, DI, design patterns and testing basics in C#.

  • Async basics
  • Task and ContinueWith
  • Async exceptions
  • Async streams
83 lessons · 7 h 0 min See lessons →
Expert

Learn memory management, unsafe code, multithreading, concurrent collections, channels and source generators in C#.

  • Memory and GC
  • Unsafe code
  • P/Invoke and interop
  • Thread and ThreadPool
47 lessons · 4 h 0 min See lessons →

Projects you will build

At every level you combine what you learned into a real page.

How does it work?

Short explanation

Each lesson explains one concept in a few short cards; no long videos or walls of text.

Try it right away

Multiple choice, fill-in-the-blank and matching exercises lock in what you just learned.

Write it yourself

You write real code in the in-browser editor; it is checked instantly and you see the result live.

Curriculum

62 groups · 362 lessons · 29 h 30 min

Learn C# and .NET fundamentals: variables, data types, loops, arrays, collections, methods and console I/O.

1
C# basics
6 lessons · 24 min
  1. 1 What is C# and .NET? Learn that C# is a powerful, modern language and how the .NET runtime works. 4 min
  2. 2 Your first program Learn to write your first C# program with the Main method, namespaces and using. 4 min
  3. 3 Console.WriteLine Learn to print text and variables to the screen with Console.WriteLine. 4 min
  4. 4 Comments Learn to write single-line (//) and multi-line (/* */) comments in C#. 3 min
  5. 5 Compile and run Learn to compile and run a C# program with dotnet run and dotnet build. 4 min
  6. 6 Summary - C# basics Combine Main, WriteLine and comments to write your first C# program. 5 min
2
Variables
6 lessons · 25 min
  1. 1 Declaring variables Learn to declare variables of type int, double, string and bool. 4 min
  2. 2 The var keyword Learn to declare variables with var where the compiler infers the type. 4 min
  3. 3 Constants Learn to declare immutable constants with the const keyword. 4 min
  4. 4 Type inference Learn how the compiler infers expression types and type compatibility. 4 min
  5. 5 Variable scope Learn the scope and visibility rules of variables inside blocks. 4 min
  6. 6 Summary - Variables Declare typed variables to write a small profile program. 5 min
3
Data types
6 lessons · 25 min
  1. 1 Integer types Learn int, long, short, byte and sbyte types and their ranges. 4 min
  2. 2 Floating-point types Learn double, float and decimal types and their precision differences. 4 min
  3. 3 Char and bool Learn to store single characters with char and logical values with bool. 3 min
  4. 4 String basics Learn to store text with string and use escape sequences. 4 min
  5. 5 Value and reference types Learn the core difference between value types and reference types. 5 min
  6. 6 Summary - Data types Combine integer, floating-point and string types to write a calculation card. 5 min
4
Project: CalculatorProject
5 lessons · 30 min
  1. 1 Project design Design the structure of the calculator project and write the skeleton code. 6 min
  2. 2 Add and subtract Add and test the addition and subtraction methods. 6 min
  3. 3 Multiply and divide Add multiplication, division and the divide-by-zero check. 6 min
  4. 4 Error handling Safely catch invalid inputs with try/catch. 6 min
  5. 5 Putting it together Combine all parts into a working calculator. 6 min
5
Operators
6 lessons · 25 min
  1. 1 Arithmetic operators Learn basic arithmetic with +, -, *, / and %. 4 min
  2. 2 Assignment operators Learn shortcut assignments with =, +=, -=, *=, /= and ++/--. 4 min
  3. 3 Comparison operators Learn to compare values with ==, !=, <, >, <= and >=. 4 min
  4. 4 Logical operators Learn boolean logic and short-circuit evaluation with &&, || and !. 4 min
  5. 5 Bitwise operators Learn bitwise operations with &, |, ^, ~, << and >>. 4 min
  6. 6 Summary - Operators Combine arithmetic, comparison and logical operators to build a grade calculator. 5 min
6
String basics
6 lessons · 26 min
  1. 1 Declaring strings Learn to declare strings with double quotes and verbatim (@) syntax. 4 min
  2. 2 String interpolation Learn to embed variables in text with $"...". 5 min
  3. 3 String concatenation Learn to join text with the + operator and string.Concat. 4 min
  4. 4 String.Format Learn placeholder-based formatting with String.Format. 4 min
  5. 5 Verbatim strings Learn to write raw text without escape sequences using @. 4 min
  6. 6 Summary - String basics Combine interpolation, concatenation and Format to write a business card. 5 min
7
Conditionals
6 lessons · 27 min
  1. 1 The if statement Learn how to check a condition with if and the code block. 4 min
  2. 2 else and else if Learn else and else if chains for alternative cases. 4 min
  3. 3 The switch statement Learn multi-way selection with switch, case, break and default. 5 min
  4. 4 Pattern matching Learn modern C# conditions with switch expressions and type patterns. 5 min
  5. 5 The ternary operator Learn to write a conditional expression in one line with ? :. 4 min
  6. 6 Summary - Conditionals Combine if, switch and pattern matching to write a day-of-week app. 5 min
8
Loops
6 lessons · 26 min
  1. 1 The for loop Learn to write counted loops with for and use a counter. 4 min
  2. 2 The while loop Learn loops that run while a condition holds with while. 4 min
  3. 3 The do-while loop Learn loops that run at least once with do-while. 4 min
  4. 4 The foreach loop Learn to iterate over collections with foreach. 5 min
  5. 5 break and continue Learn to exit a loop with break and skip with continue. 4 min
  6. 6 Summary - Loops Combine for, while and foreach to write a multiplication table. 5 min
9
Project: Shopping cartProject
5 lessons · 30 min
  1. 1 Cart design Design the shopping cart class skeleton and the product model. 6 min
  2. 2 Adding products Learn to add products to the cart with the AddProduct method. 6 min
  3. 3 Calculating totals Learn to compute the subtotal and the tax-inclusive total. 6 min
  4. 4 Updating quantity Learn to manage the cart with UpdateQuantity and RemoveProduct. 6 min
  5. 5 Putting it together Combine the cart class with a console menu. 6 min
10
Arrays
6 lessons · 26 min
  1. 1 Declaring arrays Learn to declare and initialize arrays with int[] and string[]. 4 min
  2. 2 Array access Learn to access and modify array elements by index. 4 min
  3. 3 Array length Learn to get the array length with .Length and understand bounds. 3 min
  4. 4 Multidimensional arrays Learn multidimensional arrays as matrices with int[,]. 5 min
  5. 5 Jagged arrays Learn flexible row structures with arrays of arrays (jagged). 5 min
  6. 6 Summary - Arrays Use single-dimensional and matrix arrays to write a grade table. 5 min
11
Array methods
6 lessons · 26 min
  1. 1 Array.Sort Learn to sort an array in ascending order with Array.Sort. 4 min
  2. 2 Array.Reverse Learn to reverse an array with Array.Reverse. 4 min
  3. 3 Array.IndexOf Learn to find an element's index with Array.IndexOf. 4 min
  4. 4 Array.Copy Learn to copy part of an array with Array.Copy. 4 min
  5. 5 Array.Find and FindAll Learn to find elements matching a condition with Array.Find and FindAll. 5 min
  6. 6 Summary - Array methods Combine Sort, Reverse and Find to write a class list app. 5 min
12
Collections
6 lessons · 27 min
  1. 1 List<T> basics Learn to create dynamic arrays with List<T> and call Add. 5 min
  2. 2 List<T> methods Learn to manage List<T> with Remove, Contains and Count. 4 min
  3. 3 Dictionary<K,V> Learn to store key-value pairs with Dictionary<K,V>. 5 min
  4. 4 Dictionary access Learn safe access with TryGetValue and ContainsKey. 4 min
  5. 5 HashSet<T> Learn unique-element collections with HashSet<T>. 4 min
  6. 6 Summary - Collections Combine List<T> and Dictionary<K,V> to write a phone book. 5 min
13
Methods
6 lessons · 25 min
  1. 1 Defining methods Learn how to define and call a method. 4 min
  2. 2 Return values Learn to return a value from a method with return. 4 min
  3. 3 void methods Learn void methods that do not return a value. 3 min
  4. 4 Method overloading Learn to define same-named methods with different parameters. 5 min
  5. 5 Local functions Learn to define functions inside a method. 4 min
  6. 6 Summary - Methods Combine overloading and local functions to write a math helper class. 5 min
14
Method parameters
6 lessons · 27 min
  1. 1 Parameterized methods Learn methods that take parameters and how to call them. 4 min
  2. 2 Default parameters Learn to define parameters with default values. 4 min
  3. 3 The params keyword Learn methods that take a variable number of arguments with params. 4 min
  4. 4 ref parameters Learn pass-by-reference with ref and how changes propagate to the caller. 5 min
  5. 5 out parameters Learn to return multiple values from a method with out. 5 min
  6. 6 Summary - Method parameters Combine default, params, ref and out to write a calculation method. 5 min
15
Project: To-do CLIProject
5 lessons · 30 min
  1. 1 Task model Design the Task class and its properties. 6 min
  2. 2 Adding tasks Learn to add tasks to the list with the AddTask method. 6 min
  3. 3 Listing tasks Learn to print tasks formatted with ListTasks. 6 min
  4. 4 Completing tasks Learn to update task status with CompleteTask. 6 min
  5. 5 Putting it together Build a working CLI app with a menu loop. 6 min
16
Advanced string methods
6 lessons · 25 min
  1. 1 Substring Learn to take part of a string with Substring. 4 min
  2. 2 IndexOf and LastIndexOf Learn to search with IndexOf and LastIndexOf. 4 min
  3. 3 Split and Join Learn to split with Split and join with Join. 4 min
  4. 4 Trim and Pad Learn formatting with Trim, TrimStart, PadLeft and PadRight. 4 min
  5. 5 Replace Learn to replace text inside a string with Replace. 4 min
  6. 6 Summary - Advanced strings Combine Substring, Split and Replace to write a CSV parser. 5 min
17
Console I/O
6 lessons · 26 min
  1. 1 Console.ReadLine Learn to read a line from the user with Console.ReadLine. 4 min
  2. 2 Console.ReadKey Learn to read a single key with Console.ReadKey. 3 min
  3. 3 int.Parse and TryParse Learn safe number conversion with int.Parse and TryParse. 5 min
  4. 4 double.Parse Learn to read floating-point numbers with double.Parse. 5 min
  5. 5 Console formatting Learn formatting with WriteLine format strings and alignment. 4 min
  6. 6 Summary - Console I/O Combine ReadLine, TryParse and formatting to write an interactive menu. 5 min
18
Enums
6 lessons · 26 min
  1. 1 Defining enums Learn to define named constants with the enum keyword. 4 min
  2. 2 Enum values Learn to access enum members and their values. 4 min
  3. 3 Enum casting Learn to convert between enums and int. 4 min
  4. 4 Enum.Parse Learn to convert text to enum with Enum.Parse and IsDefined. 4 min
  5. 5 Flags attribute Learn to create bit-based combinations with [Flags]. 5 min
  6. 6 Summary - Enums Combine enum and Flags to write a permission check system. 5 min
19
Exception basics
6 lessons · 27 min
  1. 1 try/catch Learn to catch runtime errors with try/catch. 5 min
  2. 2 finally block Learn cleanup code that runs even on errors with finally. 4 min
  3. 3 throw Learn to throw your own exceptions with throw. 4 min
  4. 4 The Exception class Learn the Message, StackTrace and InnerException properties of Exception. 4 min
  5. 5 Custom exceptions Learn to write your own Exception-derived class. 5 min
  6. 6 Summary - Exception basics Combine try/catch/finally and a custom exception to write a bank account class. 5 min
20
Beginner finalProject
5 lessons · 30 min
  1. 1 Project design Design the skeleton of the beginner final mini app. 6 min
  2. 2 Data model Set up the data model and collections for the app. 6 min
  3. 3 Business logic Write business rules with methods and conditional logic. 6 min
  4. 4 Error handling Add input validation and error handling with try/catch. 6 min
  5. 5 Putting it together Combine all parts into a working final app. 6 min

Learn OOP, generics, collections, LINQ, file I/O and serialization in C#.

1
Classes
6 lessons · 27 min
  1. 1 Defining classes Learn to define classes with the class keyword and instantiate with new. 5 min
  2. 2 Fields and properties Learn fields, properties and auto-property usage. 5 min
  3. 3 Methods Learn to define and call methods inside a class. 4 min
  4. 4 The this keyword Learn to reference the class itself with this. 4 min
  5. 5 Object initialization Learn to initialize objects concisely with object initializer syntax. 4 min
  6. 6 Summary - Classes Combine fields, properties and methods to write a User class. 5 min
2
Constructor
6 lessons · 27 min
  1. 1 Constructor Learn to define a class constructor. 4 min
  2. 2 Parameterized constructor Learn to initialize objects with parameterized constructors. 4 min
  3. 3 Constructor overloading Learn to define multiple constructors in the same class. 5 min
  4. 4 this() call Learn to chain to another constructor with this(). 4 min
  5. 5 Static constructor Learn the static constructor that runs once for the class. 5 min
  6. 6 Summary - Constructor Combine overloading and this() chaining to write a Product class. 5 min
3
Inheritance
6 lessons · 29 min
  1. 1 Inheritance basics Learn to inherit from a base class with the : operator. 5 min
  2. 2 The base keyword Learn to call the base class constructor and methods with base. 5 min
  3. 3 virtual and override Learn to redefine methods with virtual and override. 5 min
  4. 4 sealed Learn to prevent inheritance with sealed. 4 min
  5. 5 The Object class Learn Object, the ancestor of all classes, and ToString, Equals, GetHashCode. 5 min
  6. 6 Summary - Inheritance Combine virtual/override and base to write a shape hierarchy. 5 min
4
Project: Helper libraryProject
5 lessons · 30 min
  1. 1 Class design Design the skeleton of the helper library class. 6 min
  2. 2 String helpers Add and test string processing methods. 6 min
  3. 3 Number helpers Add number conversion and calculation methods. 6 min
  4. 4 Date helpers Add DateTime processing methods. 6 min
  5. 5 Putting it together Combine helper methods into a single class. 6 min
5
Encapsulation
6 lessons · 27 min
  1. 1 Access modifiers Learn the differences between public, private, protected and internal. 4 min
  2. 2 Properties Learn controlled access with property get/set accessors. 5 min
  3. 3 Auto-properties Learn auto-properties and assigning default values. 4 min
  4. 4 init only setters Learn init-only properties writable only during initialization. 5 min
  5. 5 Required members Learn mandatory properties with the required keyword. 4 min
  6. 6 Summary - Encapsulation Combine access modifiers, properties and init to write an Account class. 5 min
6
Static members
6 lessons · 28 min
  1. 1 Static fields Learn that static fields are shared at the class level. 4 min
  2. 2 Static methods Learn static methods and how to call them without an instance. 5 min
  3. 3 Static classes Learn how to define and use static classes. 5 min
  4. 4 const and readonly Learn the difference between const and readonly. 4 min
  5. 5 When static constructors run Learn when and how the static constructor runs. 5 min
  6. 6 Summary - Static members Combine static class, methods and readonly to write a Configuration helper. 5 min
7
Class constants
6 lessons · 27 min
  1. 1 const fields Learn to define compile-time constants with const. 4 min
  2. 2 readonly fields Learn runtime constants with readonly. 5 min
  3. 3 const vs readonly Learn the usage differences between const and readonly. 4 min
  4. 4 Static readonly Learn to define shared constants with static readonly. 5 min
  5. 5 Enum constants Learn to define grouped constants with enum. 4 min
  6. 6 Summary - Class constants Combine const, readonly and enum to write a MathConstants class. 5 min
8
Project: Quiz appProject
5 lessons · 30 min
  1. 1 Quiz model Design the skeleton of Question and Quiz classes. 6 min
  2. 2 Adding questions Learn to add questions with the AddQuestion method. 6 min
  3. 3 Running the quiz Learn to ask questions in turn with the Run method. 6 min
  4. 4 Score calculation Learn correct count and percentage with ScoreCalculator. 6 min
  5. 5 Putting it together Combine the Quiz class with a console menu. 6 min
9
Interfaces
6 lessons · 29 min
  1. 1 Defining interfaces Learn to define a contract with interface. 5 min
  2. 2 Implementing interfaces Learn how a class implements an interface. 5 min
  3. 3 Multiple interfaces Learn that a class can implement multiple interfaces. 5 min
  4. 4 Default interface methods Learn backward compatibility with default interface methods. 5 min
  5. 5 interface vs abstract Learn the difference between interface and abstract class. 4 min
  6. 6 Summary - Interfaces Combine multiple interfaces to write a payment system. 5 min
10
Abstract classes
6 lessons · 28 min
  1. 1 abstract class Learn to define and derive an abstract class. 5 min
  2. 2 abstract methods Learn abstract methods and overriding in derived classes. 5 min
  3. 3 virtual vs abstract Learn the difference between virtual and abstract methods. 4 min
  4. 4 Abstract class hierarchy Learn to build hierarchies with abstract classes. 5 min
  5. 5 sealed and abstract Learn the sealed abstract combination and its constraints. 4 min
  6. 6 Summary - Abstract classes Combine abstract methods and override to write a shape hierarchy. 5 min
11
Polymorphism
6 lessons · 29 min
  1. 1 Polymorphism basics Learn that the same call behaves differently on different types. 5 min
  2. 2 Method hiding (new) Learn to hide a base method with new and the difference. 5 min
  3. 3 is and as operators Learn type testing with is and safe casting with as. 5 min
  4. 4 Pattern matching for polymorphism Learn polymorphic dispatch with switch expressions and type patterns. 5 min
  5. 5 Virtual dispatch Learn the virtual method table and runtime dispatch. 4 min
  6. 6 Summary - Polymorphism Combine virtual, override and pattern matching to write an employee hierarchy. 5 min
12
Project: Library appProject
5 lessons · 30 min
  1. 1 Model design Design the skeleton of Book and Member classes. 6 min
  2. 2 Library class Set up collection management with the Library class. 6 min
  3. 3 Checking out Write the checkout flow with Checkout and Return methods. 6 min
  4. 4 Search and filter Write book search and filtering with LINQ. 6 min
  5. 5 Putting it together Combine the Library class with a console menu. 6 min
13
Generics basics
6 lessons · 29 min
  1. 1 Generic class Learn to define a generic class with <T>. 5 min
  2. 2 Generic methods Learn to define generic methods and call them with type arguments. 5 min
  3. 3 Type constraints Learn to constrain types with where clauses for class, struct and new(). 5 min
  4. 4 Multiple type parameters Learn multiple type parameters like <TKey, TValue>. 4 min
  5. 5 Generics vs object Learn the type-safety difference between generics and object. 5 min
  6. 6 Summary - Generics basics Combine generic class and methods to write a Stack<T>. 5 min
14
Generic collections
6 lessons · 29 min
  1. 1 List<T> in depth Learn List<T>'s _capacity and AddRange behavior. 5 min
  2. 2 Dictionary<K,V> in depth Learn Dictionary<K,V>'s hashing and collision behavior. 5 min
  3. 3 SortedDictionary Learn ordered key collections with SortedDictionary<K,V>. 4 min
  4. 4 Queue<T> and Stack<T> Learn FIFO with Queue<T> and LIFO with Stack<T>. 5 min
  5. 5 LinkedList<T> Learn doubly linked lists with LinkedList<T>. 5 min
  6. 6 Summary - Generic collections Combine List, Dictionary and Queue to write a task queue. 5 min
15
Advanced collections
6 lessons · 29 min
  1. 1 IEnumerable<T> Learn the iterable collection contract with IEnumerable<T>. 5 min
  2. 2 IEnumerator<T> Learn the iterator mechanism with IEnumerator<T>. 5 min
  3. 3 The yield keyword Learn to write iterator methods with yield return. 5 min
  4. 4 Custom collection Learn to write your own IEnumerable<T> collection. 5 min
  5. 5 SortedList and KeyedCollection Learn custom-indexed collections with SortedList and KeyedCollection. 4 min
  6. 6 Summary - Advanced collections Combine IEnumerable, yield and custom collection to write a Range class. 5 min
16
LINQ basics
6 lessons · 29 min
  1. 1 What is LINQ? Learn what LINQ is and how it queries collections. 5 min
  2. 2 Where Learn to filter elements matching a condition with Where. 5 min
  3. 3 Select Learn to transform each element with Select. 5 min
  4. 4 OrderBy Learn sorting with OrderBy and secondary sorting with ThenBy. 5 min
  5. 5 First and Single Learn to get a single element with First, FirstOrDefault and Single. 4 min
  6. 6 Summary - LINQ basics Combine Where, Select and OrderBy to write a student report. 5 min
17
LINQ methods
6 lessons · 30 min
  1. 1 Any and All Learn condition checks with Any and All. 5 min
  2. 2 Count and Sum Learn aggregate calculations with Count, Sum, Average, Min and Max. 5 min
  3. 3 Distinct and Contains Learn to deduplicate with Distinct and check membership with Contains. 5 min
  4. 4 Take and Skip Learn slicing with Take, Skip, TakeWhile and SkipWhile. 5 min
  5. 5 ToDictionary Learn collection conversion with ToDictionary and ToList. 5 min
  6. 6 Summary - LINQ methods Combine Any, Sum, Distinct and Take to write a sales report. 5 min
18
File I/O
6 lessons · 30 min
  1. 1 File.ReadAllText Learn to read a text file all at once with File.ReadAllText. 5 min
  2. 2 File.WriteAllText Learn to write a text file with File.WriteAllText. 5 min
  3. 3 File.ReadAllLines Learn to read lines as an array with File.ReadAllLines. 5 min
  4. 4 StreamReader and Writer Learn stream-based reading and writing with StreamReader and StreamWriter. 5 min
  5. 5 File.Exists and Delete Learn to check with File.Exists and delete with File.Delete. 5 min
  6. 6 Summary - File I/O Combine ReadAllText, StreamWriter and Exists to write a notes app. 5 min
19
Serialization
6 lessons · 30 min
  1. 1 JsonSerializer basics Learn to convert objects to JSON with JsonSerializer. 5 min
  2. 2 Deserialize Learn to convert JSON to objects with JsonSerializer.Deserialize. 5 min
  3. 3 JsonPropertyName Learn to customize JSON key names with [JsonPropertyName]. 5 min
  4. 4 JsonSerializerOptions Learn indentation and naming policy with JsonSerializerOptions. 5 min
  5. 5 List and dictionary serialization Learn to serialize List<T> and Dictionary<K,V> to JSON. 5 min
  6. 6 Summary - Serialization Combine Serialize, Deserialize and options to write a config file. 5 min
20
Intermediate finalProject
5 lessons · 30 min
  1. 1 Project design Design the skeleton of the intermediate final mini app. 6 min
  2. 2 OOP model Set up the class hierarchy and interfaces. 6 min
  3. 3 LINQ layer Use LINQ for data filtering and reporting. 6 min
  4. 4 File I/O Save and load data as JSON. 6 min
  5. 5 Putting it together Combine all layers into a working app. 6 min

Learn async/await, advanced LINQ, reflection, attributes, DI, design patterns and testing basics in C#.

1
Async basics
6 lessons · 30 min
  1. 1 What is async/await? Learn how the async and await keywords work. 5 min
  2. 2 The Task class Learn the asynchronous operation represented by Task. 5 min
  3. 3 Defining async methods Learn to define async methods and await them. 5 min
  4. 4 Task.Run Learn to push CPU-bound work to the background with Task.Run. 5 min
  5. 5 async/await pitfalls Learn common pitfalls like deadlock and sync-over-async. 5 min
  6. 6 Summary - Async basics Combine async/await and Task.Run to write a parallel file reader. 5 min
2
Task and ContinueWith
6 lessons · 30 min
  1. 1 Starting tasks Learn to start tasks with Task.Run and Task.Factory.StartNew. 5 min
  2. 2 ContinueWith Learn to chain after a task with ContinueWith. 5 min
  3. 3 Task.WhenAll Learn to await multiple tasks with Task.WhenAll. 5 min
  4. 4 Task.WhenAny Learn to await the first to finish with Task.WhenAny. 5 min
  5. 5 CancellationToken Learn to cancel a task with CancellationToken. 5 min
  6. 6 Summary - Task and ContinueWith Combine WhenAll, WhenAny and CancellationToken to write a parallel downloader. 5 min
3
Async exceptions
6 lessons · 30 min
  1. 1 async try/catch Learn to catch exceptions in async methods with try/catch. 5 min
  2. 2 AggregateException Learn multi-task errors with AggregateException. 5 min
  3. 3 Task.Exception Learn to inspect task errors with Task.Exception. 5 min
  4. 4 Throw timing Learn throw behavior before and after await. 5 min
  5. 5 Exception filtering Learn catch filtering with the when clause. 5 min
  6. 6 Summary - Async exceptions Combine try/catch, AggregateException and when to write a robust async wrapper. 5 min
4
Async streams
6 lessons · 30 min
  1. 1 IAsyncEnumerable Learn async iteration with IAsyncEnumerable<T>. 5 min
  2. 2 await foreach Learn to consume an async stream with await foreach. 5 min
  3. 3 yield return async Learn to write async iterator methods and yield return await. 5 min
  4. 4 Stream with CancellationToken Learn to cancel an async stream with CancellationToken. 5 min
  5. 5 System.Threading.Channels Learn producer-consumer flow with Channel<T>. 5 min
  6. 6 Summary - Async streams Combine IAsyncEnumerable, await foreach and Channel to write a log stream. 5 min
5
Advanced LINQ
6 lessons · 30 min
  1. 1 GroupBy Learn to group elements by key with GroupBy. 5 min
  2. 2 Join Learn to join two collections by key with Join. 5 min
  3. 3 GroupJoin Learn one-to-many joins with GroupJoin. 5 min
  4. 4 Aggregate Learn custom accumulation with Aggregate. 5 min
  5. 5 Zip Learn to combine two collections in parallel with Zip. 5 min
  6. 6 Summary - Advanced LINQ Combine GroupBy, Join and Aggregate to write a sales analysis report. 5 min
6
LINQ query syntax
6 lessons · 30 min
  1. 1 from clause Learn to start query syntax with from. 5 min
  2. 2 where in query Learn where in query syntax. 5 min
  3. 3 select in query Learn projection with select in query syntax. 5 min
  4. 4 orderby in query Learn orderby and ascending/descending in query syntax. 5 min
  5. 5 group by Learn group by and into in query syntax. 5 min
  6. 6 Summary - LINQ query syntax Combine from, where, select and group by to write an employee report. 5 min
7
Expression trees
6 lessons · 30 min
  1. 1 Expression<T> Learn to define an expression tree with Expression<TDelegate>. 5 min
  2. 2 Lambda to expression Learn to convert lambdas to expression trees. 5 min
  3. 3 Inspecting expression body Learn to read Expression Body, NodeType and Parameter. 5 min
  4. 4 Expression.Compile Learn to build delegates at runtime with Expression.Compile. 5 min
  5. 5 IQueryable Learn expression-based queries with IQueryable. 5 min
  6. 6 Summary - Expression trees Combine Expression and Compile to write a dynamic filter builder. 5 min
8
Reflection
6 lessons · 30 min
  1. 1 The Type class Learn to get a Type object with typeof and GetType. 5 min
  2. 2 GetMethods and GetProperties Learn to list methods and properties on a Type. 5 min
  3. 3 Activator.CreateInstance Learn dynamic instantiation with Activator.CreateInstance. 5 min
  4. 4 MethodInfo.Invoke Learn to invoke methods dynamically with MethodInfo.Invoke. 5 min
  5. 5 PropertyInfo GetValue/SetValue Learn to read and write property values with PropertyInfo. 5 min
  6. 6 Summary - Reflection Combine Type, Activator and Invoke to write a simple DI container. 5 min
9
Attributes
6 lessons · 30 min
  1. 1 Attribute basics Learn to add metadata with [Attribute]. 5 min
  2. 2 Custom attributes Learn to write your own attribute class with AttributeUsage. 5 min
  3. 3 Reading attributes Learn to read attributes with reflection. 5 min
  4. 4 Named and positional parameters Learn named and positional parameters in attributes. 5 min
  5. 5 Built-in attributes Learn attributes like [Obsolete], [Conditional] and [Serializable]. 5 min
  6. 6 Summary - Attributes Combine custom attribute and reflection to write a command handler. 5 min
10
Dependency injection
6 lessons · 30 min
  1. 1 What is DI? Learn what dependency injection is and why it is used. 5 min
  2. 2 Constructor injection Learn to pass dependencies through constructor injection. 5 min
  3. 3 ServiceCollection Learn Microsoft.Extensions.DependencyInjection ServiceCollection. 5 min
  4. 4 Lifetime: Singleton Learn single-instance services with Singleton lifetime. 5 min
  5. 5 Lifetime: Scoped and Transient Learn Scoped and Transient lifetimes. 5 min
  6. 6 Summary - DI Combine ServiceCollection and lifetimes to write a simple service registry. 5 min
11
Design patterns
6 lessons · 30 min
  1. 1 Singleton Learn to write a single-instance class with the Singleton pattern. 5 min
  2. 2 Factory Learn the object creation method with the Factory pattern. 5 min
  3. 3 Strategy Learn the family of algorithms with the Strategy pattern. 5 min
  4. 4 Observer Learn event-based notification with the Observer pattern. 5 min
  5. 5 Decorator Learn behavior extension with the Decorator pattern. 5 min
  6. 6 Summary - Design patterns Combine Singleton, Factory and Strategy to write a payment system. 5 min
12
Testing basics
6 lessons · 30 min
  1. 1 What is xUnit? Learn what the xUnit test framework is and how to use it. 5 min
  2. 2 [Fact] Learn to write test methods with [Fact]. 5 min
  3. 3 Assert Learn assertions with Assert.Equal, Assert.True and Assert.Throws. 5 min
  4. 4 [Theory] and [InlineData] Learn parameterized tests with [Theory] and [InlineData]. 5 min
  5. 5 Mock Learn to use fake objects (mocks) with Moq. 5 min
  6. 6 Summary - Testing basics Combine [Fact], [Theory] and Mock to write a calculator test. 5 min
13
Logging
6 lessons · 30 min
  1. 1 ILogger Learn the logging contract with ILogger<T>. 5 min
  2. 2 Log levels Learn LogDebug, LogInformation, LogWarning and LogError levels. 5 min
  3. 3 LoggerMessage Learn high-performance logging with LoggerMessage.Define. 5 min
  4. 4 Structured logging Learn structured logging and placeholders. 5 min
  5. 5 Log providers Learn Console and Debug log providers. 5 min
  6. 6 Summary - Logging Combine ILogger, levels and providers to write a logging sample. 5 min
14
Advanced finalProject
5 lessons · 30 min
  1. 1 Project design Design the skeleton of the advanced final mini app. 6 min
  2. 2 Async layer Set up data flow using async/await and Task. 6 min
  3. 3 Reflection and attributes Write command handling with reflection and custom attributes. 6 min
  4. 4 DI and tests Set up DI container and xUnit tests. 6 min
  5. 5 Putting it together Combine all layers into a working mini framework. 6 min

Learn memory management, unsafe code, multithreading, concurrent collections, channels and source generators in C#.

1
Memory and GC
6 lessons · 30 min
  1. 1 GC basics Learn how the garbage collector (GC) works and its generations. 5 min
  2. 2 IDisposable Learn to release unmanaged resources with IDisposable. 5 min
  3. 3 using statement Learn automatic dispose with the using statement and using declaration. 5 min
  4. 4 GC.Collect Learn memory management with GC.Collect and GC.GetTotalMemory. 5 min
  5. 5 Large Object Heap Learn the Large Object Heap (LOH) and large object behavior. 5 min
  6. 6 Summary - Memory and GC Combine IDisposable, using and GC to write a resource pool. 5 min
2
Unsafe code
6 lessons · 30 min
  1. 1 unsafe block Learn the unsafe block and pointer usage. 5 min
  2. 2 Pointers Learn memory addresses with pointers like int*. 5 min
  3. 3 fixed statement Learn to pin a managed object with fixed. 5 min
  4. 4 stackalloc Learn to allocate on the stack with stackalloc. 5 min
  5. 5 Span<T> Learn safe memory views with Span<T>. 5 min
  6. 6 Summary - Unsafe code Combine unsafe, fixed and Span<T> to write a fast buffer copy. 5 min
3
P/Invoke and interop
6 lessons · 30 min
  1. 1 DllImport Learn to call native libraries with DllImport. 5 min
  2. 2 Marshal Learn managed/unmanaged conversion with the Marshal class. 5 min
  3. 3 StructLayout Learn to control memory layout with StructLayout. 5 min
  4. 4 String marshalling Learn to pass managed strings to native APIs. 5 min
  5. 5 Function pointer Learn unmanaged function pointers with delegate*. 5 min
  6. 6 Summary - P/Invoke and interop Combine DllImport, Marshal and StructLayout to write a native wrapper. 5 min
4
Thread and ThreadPool
6 lessons · 30 min
  1. 1 The Thread class Learn to create threads with System.Threading.Thread. 5 min
  2. 2 Thread.Start Learn to start threads with Thread.Start and wait with Join. 5 min
  3. 3 ThreadPool Learn the thread pool with ThreadPool. 5 min
  4. 4 The lock statement Learn critical section protection with lock. 5 min
  5. 5 Interlocked Learn atomic operations with Interlocked. 5 min
  6. 6 Summary - Thread and ThreadPool Combine Thread, lock and Interlocked to write a counter. 5 min
5
Concurrent collections
6 lessons · 30 min
  1. 1 ConcurrentDictionary Learn the thread-safe dictionary with ConcurrentDictionary. 5 min
  2. 2 ConcurrentQueue Learn the thread-safe queue with ConcurrentQueue. 5 min
  3. 3 ConcurrentStack Learn the thread-safe stack with ConcurrentStack. 5 min
  4. 4 ConcurrentBag Learn the unordered thread-safe bag with ConcurrentBag. 5 min
  5. 5 BlockingCollection Learn the producer-consumer pattern with BlockingCollection. 5 min
  6. 6 Summary - Concurrent collections Combine ConcurrentDictionary and BlockingCollection to write a work queue. 5 min
6
Channels
6 lessons · 30 min
  1. 1 Channel.Create Learn to create channels with Channel.CreateBounded and CreateUnbounded. 5 min
  2. 2 ChannelWriter Learn to write to a channel with ChannelWriter<T>. 5 min
  3. 3 ChannelReader Learn to read from a channel with ChannelReader<T>. 5 min
  4. 4 Bounded channel Learn backpressure and WaitToWriteAsync in bounded channels. 5 min
  5. 5 Channel completion Learn to close a channel with Channel.Writer.Complete and Completion. 5 min
  6. 6 Summary - Channels Combine ChannelWriter, ChannelReader and Complete to write a log processor. 5 min
7
Source generators
6 lessons · 30 min
  1. 1 What are source generators? Learn what source generators are and compile-time code generation. 5 min
  2. 2 IIncrementalGenerator Learn to write incremental source generators with IIncrementalGenerator. 5 min
  3. 3 Generator attribute Learn source generator registration with the [Generator] attribute. 5 min
  4. 4 Syntax receiver Learn to scan the AST during compilation with SyntaxReceiver. 5 min
  5. 5 AddSource Learn to add generated code to the compilation with AddSource. 5 min
  6. 6 Summary - Source generators Combine IIncrementalGenerator and AddSource to write a DTO generator. 5 min
8
Expert finalProject
5 lessons · 30 min
  1. 1 Project design Design the skeleton of the expert final mini app. 6 min
  2. 2 Memory and Span Write high-performance operations with Span<T> and unsafe code. 6 min
  3. 3 Channels and concurrent Write a parallel pipeline with channels and concurrent collections. 6 min
  4. 4 Source generator Generate code at compile time with a source generator. 6 min
  5. 5 Putting it together Combine all expert topics into a working mini app. 6 min

Lessons are free, an account keeps your progress

You do not have to sign up. If you do, you continue where you left off and never lose your work.

  • Progress saved on every device
  • Earn XP and badges
  • Keep your daily streak
  • Get a certificate when you finish
create a free account

Frequently asked questions

Are the C# lessons free?

Yes. All 362 lessons of the C# course are free and you can start without an account.

Do I need any prior knowledge?

No. The beginner level starts from zero; a browser is all you need. If you already know the basics, start at a higher level.

How long does the course take?

Lessons take 2–8 minutes. The whole course is about 30 hours; with 15–20 minutes a day you can finish in a few months.

Do I get a certificate?

Yes. When you complete the course with a free account, a verifiable certificate is issued in your name.

Will I lose my progress without an account?

Without an account your progress is kept only in your current browser. When you create a free account it is moved to your account.