C# Tutorial
Learn C# 14 on .NET 10 from your first program to LINQ, async, ASP.NET Core and real projects. 182 lessons with C# that compiles and runs in your browser, quizzes and projects.
Start learning →
of lessons completed
Getting Started
- Getting Started with C# Start learning C# 14 on .NET 10. Learn what C# and .NET are, where they are used, and write and run your first program right in your browser.
- How C# and .NET Work Understand how C# source code becomes a running program on .NET 10 - the Roslyn compiler, IL, assemblies, the JIT and CLR, NuGet, and the dotnet CLI.
- CTS, CLS, Managed Code and Assemblies Understand the .NET vocabulary behind C# - the Common Type System, the Common Language Specification, managed and unmanaged code, assemblies and metadata, and how .NET Framework became .NET 10.
- C# Syntax Learn the basic C# syntax - statements, blocks, case sensitivity, naming conventions, namespaces, using directives and how to read compiler error codes.
- Program Structure: Top-Level Statements and Main Learn how a C# program starts - top-level statements, the generated Program class, an explicit Main method, args, exit codes, async Main and file layout.
- Comments and XML Documentation Learn C# comments - single-line, multi-line and /// XML documentation comments, common doc tags, #region, #pragma, #nullable directives and good commenting habits.
- Console Output and Formatting Print text in C# with Console.Write and WriteLine, string interpolation, composite formatting, format specifiers (N2, C, P, D, X, E), alignment and Console.Error.
- Reading Input Learn how C# programs read input - Console.ReadLine and null at end of input, parsing with int.Parse and TryParse, validation loops and reading all lines at once.
- The dotnet CLI, Projects and Tooling Learn the dotnet CLI commands, how a .csproj file works, what Nullable and ImplicitUsings do, file-based apps, global.json and which editor to pick for C#.
Variables and Types
- Variables and var Learn C# variables - declaring and assigning, definite assignment, var type inference, default values, scope rules, naming conventions and discards.
- Constants and readonly Learn the difference between const, readonly and static readonly in C# - compile-time constants, constant expressions, versioning traps and when to use each.
- Value Types and Reference Types Understand C# value types and reference types - copy semantics, null, the stack and heap, boxing, struct vs class, the type hierarchy and ReferenceEquals.
- Integer Types Learn every C# integer type from sbyte to ulong, nint, Int128 and BigInteger - ranges, literals, overflow, checked and unchecked, and integer division pitfalls.
- Floating-Point and decimal Learn C# float, double, decimal and Half - why 0.1 + 0.2 is not 0.3, NaN and Infinity, decimal for money, Math.Round modes and comparing with a tolerance.
- bool and char Learn the C# bool and char types - true and false, logical operators, char as a UTF-16 code unit, escape sequences, char.IsLetter and friends, surrogate pairs and char arithmetic.
- Type Conversion and Casting Learn C# type conversion - implicit and explicit casts, truncation and overflow, the Convert class, Parse and TryParse, is and as, user-defined conversions and BitConverter.
- Nullable Value Types Learn C# nullable value types - int?, HasValue, Value, GetValueOrDefault, lifted operators, the ?? and ??= operators, null propagation and boxing of nullable values.
- Enums and Flags Learn C# enums - declaring named constants, underlying types, Enum.Parse and TryParse, GetValues, [Flags] with bitwise operations, switch expressions and the undefined value pitfall.
Operators and Control Flow
- Operators Learn every everyday C# operator - arithmetic, comparison, short-circuit logic, bitwise and shift (including >>>), compound assignment, ++ and --, the ternary operator and precedence.
- if, else if and else Learn C# if, else if and else statements - conditions, nesting, guard clauses, the ternary operator, simplifying boolean logic and the mistakes that trip up beginners.
- switch Statements and Expressions Learn the C# switch statement and the modern switch expression - case labels, fall-through rules, goto case, when guards, exhaustiveness, the discard pattern and when to choose each form.
- while, do-while and for Loops Learn the three classic C# loops - while, do-while and for - with loop variable scope, nested loops, infinite loops with break, loop invariants and how to avoid off-by-one errors.
- foreach and Iteration Learn the C# foreach loop - iterating arrays, lists, strings and dictionaries, the read-only iteration variable, why modifying a collection throws, and getting indexes with Index().
- break, continue, goto and return Learn the C# jump statements - break, continue, return, throw and goto with labels - and the best ways to leave nested loops, plus common traps such as break inside a switch.
- Ranges and Indices Learn C# index-from-end (^1) and range (1..3) syntax, the Index and Range types, slicing arrays, strings and spans, and how to make your own types support ranges.
- Pattern Matching Basics Learn the basics of C# pattern matching - the is operator, type, constant, null, relational and logical patterns, property patterns, and how patterns work in switch expressions.
Strings
- Strings Learn how C# strings work - immutability, creating strings, string vs String, null and empty checks, equality, StringComparison, ordinal vs culture rules and interning.
- Working with Strings A practical guide to C# string methods - Substring, IndexOf, Contains, Replace, Split, Join, Trim, Pad, Insert, Remove, case conversion, spans and counting characters.
- Interpolation and Formatting Master C# string interpolation and formatting - alignment, format specifiers, IFormatProvider and culture, custom ToString and IFormattable, string.Format and interpolated string handlers.
- StringBuilder Learn why repeated string concatenation is slow and how StringBuilder fixes it - Append, Insert, Remove, capacity, AppendJoin, chunks, plus string.Concat, string.Join and string.Create.
- Raw, Verbatim and UTF-8 String Literals Learn C# string literal forms - escape sequences, verbatim @ strings, raw string literals with triple quotes and interpolation, indentation rules, multi-line text and u8 UTF-8 literals.
- Unicode, Rune and Encoding Understand UTF-16 code units, surrogate pairs, Rune, text elements, Encoding.UTF8 byte counts and Unicode normalization in C#, with runnable examples and common pitfalls.
- Regular Expressions Learn C# regular expressions with System.Text.RegularExpressions - IsMatch, Match, Matches, Replace, Split, named groups, options, GeneratedRegex and how to avoid catastrophic backtracking.
Methods
- Methods Learn how to write and call C# methods - declaration syntax, parameters and arguments, return values, void, overloading, method signatures, naming rules, static vs instance methods and XML docs.
- Parameters: ref, out, in and params Master C# parameter passing - by value vs by reference, ref, out variables and discards, in and ref readonly, params arrays and params collections (C# 13), plus ref returns and ref locals.
- Optional and Named Arguments Learn C# optional parameters with default values, named arguments and their ordering rules, how overloads compete with defaults, and the CallerMemberName and CallerArgumentExpression attributes.
- Expression-Bodied Members and Local Functions Learn C# expression-bodied members with =>, throw expressions, local functions, static local functions, closures versus static, and recursion inside local functions, with runnable examples.
- Recursion Learn recursion in C# - base cases, how the call stack grows, why StackOverflowException cannot be caught, memoization with Dictionary, and when a loop is better.
- Lambda Expressions Learn C# lambda expressions - the => syntax, Func and Action, natural types, captured variables, static lambdas, default parameters and attributes, with runnable examples.
- Tuples and Deconstruction Learn C# tuples - ValueTuple syntax, named elements, returning several values from a method, deconstruction, discards, tuple equality, and when to use records or out instead.
Collections
- Arrays Learn C# arrays - creating and initializing, indexing, Length, multidimensional vs jagged arrays, Array.Sort, Copy, Resize, IndexOf, covariance pitfalls and array vs List.
- List of T Learn C# List<T> - creating, Add, Insert, Remove, RemoveAll, IndexOf, Contains, Sort with Comparison, capacity growth, performance costs and common pitfalls.
- Dictionary of TKey, TValue Learn the C# Dictionary<TKey, TValue> - adding, indexer, TryGetValue, GetValueOrDefault, TryAdd, iteration, key equality and GetHashCode, custom comparers and ordering.
- HashSet, SortedSet and Set Operations Learn C# sets - HashSet and SortedSet, uniqueness, Add returning a bool, union, intersection, difference, subset checks, custom comparers and what each operation costs.
- Stack, Queue, LinkedList and PriorityQueue Learn the C# collections for ordering work - Stack (LIFO), Queue (FIFO), LinkedList nodes and PriorityQueue - with Peek, TryPeek, BFS, undo history and task scheduling examples.
- SortedDictionary, SortedList and Ordering Learn C# sorted collections - SortedDictionary vs SortedList vs Dictionary, binary search, IComparable and IComparer, custom ordering, and why List.Sort is unstable but OrderBy is stable.
- Collection Expressions and Spread Learn C# 12 collection expressions - the [1, 2, ..other] syntax, target types, the spread element, empty [], custom collection builders and the performance behind them.
- Immutable, Frozen and Read-only Collections Learn the difference between read-only views, ImmutableArray, ImmutableList, ImmutableDictionary and FrozenDictionary in C#, with builders, copy-on-change behaviour and when to choose each.
- IEnumerable, ICollection and IList Understand the C# collection interface hierarchy - IEnumerable, ICollection, IList - how foreach and IEnumerator work by hand, yield return, custom collections and covariance.
- Non-Generic and Specialized Collections Meet the pre-generics C# collections - ArrayList, Hashtable, BitArray, OrderedDictionary and NameValueCollection - see why generics replaced them, and learn how to migrate old code.
- Choosing the Right Collection Pick the right C# collection for the job - List, Dictionary, HashSet, Queue, Stack, SortedSet, Frozen and Concurrent collections - with a decision table, Big O costs and runnable demos.
- IComparable and IComparer Learn how C# decides what "smaller" means. Implement IComparable<T>, write IComparer<T> classes and Comparison delegates, sort by several keys and avoid common bugs.
Classes and Objects
- Classes and Objects Learn C# classes and objects from scratch - declaring a class, fields, methods, new, reference semantics, null, object initializers, and the difference between static and instance members.
- Properties Master C# properties - get and set accessors, auto-properties, init-only and required members, computed properties, validation in setters, backing fields and the C# 14 field keyword.
- Constructors and Object Initialization Learn C# constructors - default and overloaded constructors, this(...) chaining, static constructors, object and collection initializers, and the exact order in which an object is initialized.
- Primary Constructors Learn C# 12 primary constructors for classes and structs - captured parameters, initializers, validation, how they differ from records, dependency injection use and when to avoid them.
- Static Members and Static Classes Understand C# static fields, methods, properties and classes - when shared state makes sense, extension method classes, the singleton pattern, and why global state hurts testing and dependency injection.
- Access Modifiers and Encapsulation Learn C# access modifiers - public, private, protected, internal, protected internal, private protected and file - and how encapsulation keeps objects valid and code easy to change.
- Inheritance Learn C# inheritance - base and derived classes, calling base constructors, protected members, sealed classes, is-a versus has-a and why composition often beats inheritance.
- Polymorphism: virtual, override and new Learn C# polymorphism - virtual and override methods, dynamic dispatch, calling base, abstract members, covariant returns and the new keyword hiding trap, with runnable examples.
- Abstract Classes and Interfaces Learn C# abstract classes and interfaces - when to use each, explicit implementation, default interface methods, static abstract members and a clear rule for choosing between them.
- The object Class: Equals, GetHashCode and ToString Learn the C# object methods - reference vs value equality, overriding Equals and GetHashCode together, IEquatable<T>, ToString, GetType and MemberwiseClone with runnable examples.
- Records Learn C# records - positional records, value equality, with-expressions, deconstruction, init-only properties, inheritance, record struct and readonly record struct, with runnable examples.
- Structs Learn C# structs - copy semantics, struct vs class, constructors and default values, readonly structs, the mutable struct trap, record struct, ref struct and when to choose a struct.
- Operator Overloading and Conversions Learn C# operator overloading - arithmetic, comparison and equality operators, implicit and explicit conversions, true/false, checked operators and C# 14 compound assignment operators.
- Indexers and Custom Iterators Learn C# indexers (this[]), multi-parameter and string indexers, Index and Range support, how foreach calls GetEnumerator, writing iterators with yield return and building a custom collection.
- Extension Methods and Extension Members Learn C# extension methods - the this parameter, static classes, namespaces and discoverability, how LINQ works, plus C# 14 extension blocks with extension properties and static members.
- Partial, Nested and Local Types Learn C# partial classes, partial methods and partial properties, how code generators use them, nested types, file-scoped types, anonymous types and why C# has no local classes.
- Designing with Objects: SOLID in C# Learn the SOLID principles in C# with small runnable examples - single responsibility, open/closed, Liskov substitution, interface segregation, dependency inversion, plus composition and immutability.
Generics
- Generics Learn C# generics from scratch: generic classes, methods and interfaces, type parameters, inference, default(T), and why generics beat object and boxing.
- Generic Constraints Learn C# generic constraints: class, struct, new(), notnull, unmanaged, base classes, interfaces, combining them, allows ref struct, and good design.
- Generic Methods and Delegates Learn C# generic methods and delegates: type inference rules, explicit type arguments, Func and custom delegates, per-type caching and reflection basics.
- Covariance and Contravariance Understand C# covariance and contravariance with out and in, IEnumerable of T, Func and Action variance, the array covariance trap and variant interfaces.
- Generic Math and Static Abstract Members Learn C# generic math (C# 11, .NET 7): INumber of T, operator interfaces, writing Sum once for all numeric types, static abstract members and parsing.
Delegates, Events and LINQ
- Delegates Learn C# delegates: delegate types, Func, Action and Predicate, method groups, multicast, safe invocation, callbacks, strategies and allocation costs.
- Events Learn C# events step by step - the event keyword, EventHandler<T>, event args, subscribing and unsubscribing, memory leaks, thread-safety and weak event ideas.
- LINQ Basics Learn LINQ in C# from scratch - Where, Select, OrderBy, First, Any, Count, ToList, anonymous projections and how an IEnumerable pipeline works, with runnable examples.
- LINQ Operators in Depth Go beyond Where and Select - GroupBy, Join, GroupJoin, LeftJoin, SelectMany, Zip, Aggregate, set operations, Chunk, CountBy and AggregateBy in C# with runnable examples.
- Deferred Execution and LINQ Pitfalls Understand LINQ deferred execution in C# - lazy queries, multiple enumeration, ToList snapshots, captured variables, side effects, stable sorting and LINQ versus loops.
- LINQ Query Syntax Learn C# LINQ query syntax - from, where, select, orderby, group by, join, let and into - how it translates to method calls, and when it reads better than method syntax.
- LINQ Practice: Reports and Transformations Practice C# LINQ on a small dataset - top-N, grouped totals, pivot tables, flattening, paging, sliding windows with Zip and Chunk, with runnable worked examples.
- Iterators and yield Learn how C# iterators work - yield return, yield break, the compiler state machine, lazy and infinite sequences, exceptions and finally in iterators, validation, and a preview of IAsyncEnumerable.
Null Safety and Errors
- Nullable Reference Types Learn C# nullable reference types - string versus string?, compiler flow analysis, the null-forgiving operator, nullable attributes, required members, and how to migrate an old codebase safely.
- Null-Handling Operators Master C# null-handling operators - null-conditional ?. and ?[], null-coalescing ?? and ??=, is null patterns, C# 14 null-conditional assignment, ThrowIfNull and the null object pattern.
- Exceptions Learn C# exception handling - try/catch/finally, the exception hierarchy, catch order, throw versus throw ex, stack traces, finally ordering, unhandled exceptions and exit codes, with runnable examples.
- Custom Exceptions and Exception Design Learn to write custom exception classes in C#, add data, chain InnerException, handle AggregateException, decide between throwing and returning errors, and use guard clauses like ThrowIfNull.
- Exception Filters and Error Handling Patterns Learn C# exception filters with when, the TryParse pattern, Result types, ExceptionDispatchInfo, retry with backoff, and global handlers for unhandled exceptions, with runnable examples.
- IDisposable, using and Finalizers Learn how C# releases files, connections and other resources with IDisposable, using statements and declarations, the dispose pattern, finalizers and await using.
- Validating Input and Defensive Programming Learn how to validate arguments, guard preconditions, use Debug.Assert, DataAnnotations and invariants, and fail fast so bugs in C# programs are caught early and clearly.
Pattern Matching and Modern C#
- Pattern Matching in Depth Master advanced C# pattern matching - nested property patterns, positional patterns, var and discard patterns, switch expressions, when guards, parentheses and exhaustiveness.
- List and Slice Patterns Learn C# 11 list patterns and slice patterns - match arrays, lists, strings and spans by shape with [first, .., last], capture slices with var, and write small parsers.
- Modeling with Records and Pattern Matching Model data with sealed record hierarchies and pattern matching in C#. Build discriminated-union style types, state machines and an expression evaluator, plus a look at the union proposal.
- What's New in C# 8 to 14 A version-by-version tour of C# 8 to 14 with short runnable examples - nullable references, records, raw strings, primary constructors, collection expressions, the field keyword and extension members.
- C# 14 Features in Depth A hands-on tour of C# 14 on .NET 10 - extension members, the field keyword, null-conditional assignment, span conversions, partial constructors, lambda modifiers and more.
Async and Concurrency
- Threads Learn C# threads from scratch - starting a Thread, Join, foreground and background threads, race conditions and lock, the ThreadPool, ThreadLocal and why tasks are usually better.
- Tasks and the Task Parallel Library Learn C# tasks - Task.Run, Task<T>, Wait and Result pitfalls, continuations, exceptions inside tasks, TaskCompletionSource and Task.Delay, with runnable examples.
- async and await Understand C# async and await - how the state machine works, writing async methods, the async void trap, ConfigureAwait, async Main, sync-over-async deadlocks and ValueTask.
- WhenAll, WhenAny and Task.WhenEach Combine tasks in C# - Task.WhenAll, Task.WhenAny, Task.WhenEach, timeouts with WaitAsync, Parallel.ForEachAsync and throttling async work with SemaphoreSlim.
- Cancellation and Timeouts Learn cooperative cancellation in C# - CancellationTokenSource, CancellationToken, OperationCanceledException, CancelAfter timeouts, linked tokens and PeriodicTimer.
- Parallel and PLINQ Learn data parallelism in C# - Parallel.For, Parallel.ForEach, Parallel.Invoke, ForEachAsync, PLINQ with AsParallel and AsOrdered, partitioning, and when parallel code is slower.
- lock, Lock and Interlocked Make shared data thread-safe in C# - the lock statement, System.Threading.Lock, Monitor, Interlocked, Volatile, deadlocks and how to avoid them, SemaphoreSlim and ReaderWriterLockSlim.
- Concurrent Collections Learn the thread-safe collections in C# - ConcurrentDictionary and its GetOrAdd pitfall, ConcurrentQueue, ConcurrentBag, BlockingCollection, and immutable snapshots as an alternative to locking.
- Channels and Producer-Consumer Learn System.Threading.Channels in C# - bounded and unbounded channels, writers and readers, back-pressure, multiple consumers, pipelines, completion, errors and await foreach with ReadAllAsync.
- Async Streams Learn async streams in C# - IAsyncEnumerable of T, await foreach, async iterator methods with yield return, cancellation with EnumeratorCancellation, paging APIs, cleanup and async LINQ in .NET 10.
- Async Patterns and Pitfalls Avoid the classic async and await mistakes in C# - forgotten await, fire-and-forget, async void, sync-over-async deadlocks, context capture, lost exceptions, async disposal, testing, and a checklist.
- Timers: PeriodicTimer and System.Threading.Timer Run recurring work in C# with PeriodicTimer, System.Threading.Timer and Task.Delay loops. Learn which to choose, how to stop cleanly and how to avoid overlapping ticks.
Memory and Performance
- Garbage Collection Understand how the .NET garbage collector finds dead objects, why it uses generations, what roots and finalizers are, and how to work with it instead of fighting it.
- Span, Memory and Slicing Learn Span<T>, ReadOnlySpan<T>, stackalloc and Memory<T> in C#: slice arrays and strings without allocating, parse text fast and understand the ref struct rules.
- Boxing, Unboxing and Value Semantics Learn what boxing and unboxing do in C#, how to count the allocations they cause, how generics avoid them, and how struct copying, readonly struct and in parameters work.
- Measuring and Improving Performance Learn how to measure C# performance honestly: Stopwatch pitfalls, counting operations and allocations, BenchmarkDotNet, and the common wins such as StringBuilder and sized collections.
- Fast Lookups: SearchValues, FrozenDictionary and Caching Speed up repeated lookups in C# with SearchValues, FrozenDictionary and FrozenSet, MemoryCache, Lazy<T> and ArrayPool, and learn when each tool is worth its complexity.
- Unsafe Code and Interop Learn when and how to use unsafe code in C#: pointers, fixed, stackalloc, NativeMemory, Marshal and P/Invoke for calling native libraries, plus NativeAOT limits and safer options.
- Benchmarking with BenchmarkDotNet Learn to measure C# performance correctly - why Stopwatch timings mislead, how BenchmarkDotNet warms up and repeats, memory diagnosers, Params, baselines and how to read the results.
Standard Library
- Dates and Times Learn C# dates and times - DateTime kinds, DateTimeOffset, TimeSpan, DateOnly, TimeOnly, formatting, parsing, time zones and TimeProvider for testable code.
- Math, BigInteger and Random Learn the C# Math class, rounding modes, BigInteger, Complex, Int128, seeded Random, secure random numbers and safe number parsing, with runnable examples.
- Files, Paths and Directories Learn C# file handling - File, Directory and Path classes, reading and writing text, File.ReadLines, FileStream, async I/O, temp files and safe path handling.
- Streams, Readers and Writers Learn C# streams - Stream, MemoryStream, StreamReader and StreamWriter, BinaryReader and BinaryWriter, buffering, GZip and Brotli compression, and pipelines.
- JSON with System.Text.Json Learn System.Text.Json in C# - serialize and deserialize objects and records, naming policies, attributes, JsonDocument, JsonNode, custom converters and polymorphism.
- XML, CSV and Other Formats Learn to work with XML using LINQ to XML and XmlSerializer, write and parse CSV by hand, encode Base64 and hex, use UTF-8 helpers and parse URIs in C#.
- HttpClient Learn C# HttpClient: send GET and POST requests, read status codes and headers, use JSON helpers, set timeouts, reuse clients and meet IHttpClientFactory.
- Environment, Arguments and Process Learn how C# programs talk to their surroundings: command-line args, environment variables, exit codes, console redirection, Process, Stopwatch and culture.
- Reflection and Attributes Learn C# reflection: typeof and GetType, reading properties and methods, Activator, custom attributes, generic types, performance costs and source generators.
- Expression Trees and Dynamic Learn C# expression trees: Expression<Func<>>, building and compiling code at run time, visiting trees, plus dynamic, ExpandoObject and the DLR.
- TCP, UDP and Named Pipes Learn network programming in C#: build a TCP echo server with TcpListener and TcpClient, send UDP datagrams, use raw Socket, and talk between processes with named pipes.
- Zip and GZip Compression Learn C# compression with System.IO.Compression. Use GZipStream, DeflateStream and BrotliStream, compress strings and files, and create and read ZIP archives in memory.
- Cryptography and Hashing Learn practical C# cryptography with System.Security.Cryptography - SHA-256 hashing, HMAC, AES-GCM encryption, random bytes, and password hashing with PBKDF2.
- Images with ImageSharp Learn image processing in C#: load, resize, crop, convert and draw on images with SixLabors ImageSharp, plus how pixels work, shown with runnable pixel-buffer examples.
- Localization and Globalization Learn globalization and localization in C# and ASP.NET Core - cultures, number and date formats, resource files with fallback, plural rules and Accept-Language negotiation - with runnable demos.
Dependency Injection and Hosting
- Dependency Injection Learn dependency injection in C#: the idea, constructor injection, ServiceCollection, singleton, scoped and transient lifetimes, keyed services and captive dependencies.
- Configuration and Options Learn .NET configuration: IConfiguration from memory and JSON, binding to classes, IOptions, IOptionsSnapshot, IOptionsMonitor, validation and environment layering.
- Logging Learn logging in C# with Microsoft.Extensions.Logging - ILogger<T>, log levels, structured message templates, scopes, filtering, custom providers, LoggerMessage and common pitfalls.
- The Generic Host and BackgroundService Learn the .NET Generic Host - Host.CreateApplicationBuilder, hosted services, BackgroundService, cancellation, graceful shutdown, lifetime events, scoped services in workers and worker patterns.
- Caching and HttpClientFactory Learn in-memory caching with IMemoryCache - expiration, GetOrCreate, size limits, cache stampede - and typed HttpClients with IHttpClientFactory, handlers and resilience in .NET.
ASP.NET Core
- ASP.NET Core Overview Meet ASP.NET Core - the app types (minimal APIs, MVC, Razor Pages, Blazor, SignalR, gRPC), Kestrel, WebApplication, the request pipeline - and run your first web server and call it with HttpClient.
- Minimal APIs Build HTTP APIs with ASP.NET Core minimal APIs - MapGet, MapPost, MapPut, MapDelete, parameter binding, TypedResults, JSON, status codes, route groups and clean project organization.
- Routing and Model Binding Understand ASP.NET Core routing and model binding - route templates, constraints, optional and catch-all segments, query, header, body and form binding, AsParameters, TryParse and BindAsync.
- Middleware and the Request Pipeline Learn ASP.NET Core middleware in C# - the request pipeline, Use, Run and Map, ordering, short-circuiting, middleware classes, exception handling, request logging and endpoint filters.
- Validation and Problem Details Validate input in C# web APIs with DataAnnotations, IValidatableObject and endpoint filters, and return consistent errors with ProblemDetails, ValidationProblem and IExceptionHandler.
- Authentication and Authorization Understand authentication vs authorization in ASP.NET Core - claims, schemes, cookies vs JWT bearer tokens, policies, roles, 401 vs 403 and safe password hashing, with runnable C# demos.
- REST API Design with ASP.NET Core Design clean REST APIs in ASP.NET Core - resource modeling, status codes, pagination, idempotency, versioning, ETags, OpenAPI documents and a pragmatic take on HATEOAS, with runnable C# examples.
- MVC, Razor Pages and Blazor Compare ASP.NET Core MVC, Razor Pages, Blazor and minimal APIs - controllers, views, Razor syntax, tag helpers, model binding and validation, and how to choose, with runnable C# controller demos.
- SignalR, WebSockets and gRPC Learn real-time communication in ASP.NET Core - long polling, Server-Sent Events, WebSockets, SignalR hubs on the wire and gRPC streaming - with runnable C# loopback demos and guidance on choosing.
- Publishing and Deploying .NET Apps Learn how to publish a .NET app: framework-dependent vs self-contained, single-file, Native AOT, Docker, health checks, production configuration and graceful shutdown.
- Health Checks and Rate Limiting Run ASP.NET Core in production with health checks (tags, degraded state, timeouts, JSON reports) and built-in rate limiting (fixed window, sliding window, token bucket, concurrency, per-client policies).
- Blazor Components Learn Blazor components in depth - parameters, child content, lifecycle, EventCallback, cascading values, state containers and EditForm validation - with real Blazor components rendered by runnable C# code.
- OpenAPI Docs and GraphQL Document ASP.NET Core APIs with OpenAPI and Swagger UI, then learn how GraphQL works - schemas, queries, resolvers, the N+1 problem and Hot Chocolate - with a runnable mini OpenAPI generator and GraphQL engine.
- Resilience with Polly Build resilient .NET apps - transient faults, retry with backoff and jitter, timeouts, circuit breakers, hedging and fallbacks with Polly v8, plus runnable hand-written versions of each idea.
Data Access
- Data Access in .NET A map of .NET data access: ADO.NET, micro-ORMs like Dapper and full ORMs like EF Core, how to choose, connection strings, and a runnable DataTable and mapper demo.
- ADO.NET Concepts Learn ADO.NET in C#: connections, commands, DataReader, parameters against SQL injection, transactions, DataTable change tracking and DataView, with runnable demos.
- Entity Framework Core Learn EF Core: DbContext, entities, migrations, how LINQ becomes SQL, change tracking, relationships, Include and N+1, with runnable stand-ins that show how it works.
- Repositories, Unit of Work and Clean Architecture Understand the repository and unit of work patterns in C#, what EF Core already gives you, specifications, testing with fakes, and Clean Architecture dependencies, with runnable code.
- Working with SQL and NoSQL from C# Real database work in C#: optimistic and pessimistic concurrency, isolation levels, retries and connection resilience, pagination, plus Redis and MongoDB basics with runnable models.
Testing and Quality
- Testing Fundamentals Learn the basics of testing C# code - unit, integration and end-to-end tests, Arrange-Act-Assert, test doubles, test-driven development and a hand-written mini test runner you can run.
- xUnit, NUnit and MSTest Compare the three .NET test frameworks - attributes, assertions, theories and data-driven tests, fixtures and lifecycle - with read-only real code and runnable stand-ins you can experiment with.
- Mocks, Stubs and Fakes Learn test doubles in C# - interface seams, hand-written stubs, fakes and spies, faking time with TimeProvider, how Moq and NSubstitute work, a runnable mini mock, and how to avoid over-mocking.
- Debugging and Diagnostics Learn to debug C# programs - breakpoints, reading stack traces, Debug.Assert, Trace listeners, caller info, Activity tracing, Meter metrics and the dotnet-counters, dotnet-trace and dotnet-dump tools.
- Analyzers, Code Style and Warnings Learn how Roslyn analyzers, .editorconfig, warning severities, TreatWarningsAsErrors, nullable warnings and dotnet format keep C# code consistent and safe, with real compiler warnings you can run.
- Design Patterns in C# Learn the design patterns C# developers use daily - strategy, observer, factory, builder, decorator, adapter, repository, singleton via DI and mediator - with short runnable examples and advice on when not to use them.
- Secure C# Coding Write safer C# and ASP.NET Core code - stop SQL injection and XSS, validate paths, hash passwords, block CSRF with antiforgery tokens, keep secrets out of source and use Data Protection.
- Integration Testing ASP.NET Core Test ASP.NET Core apps end to end with WebApplicationFactory - real routing, middleware and DI, replacing services and configuration, databases, authentication, and runnable examples.
Advanced C#
- Source Generators and Roslyn Learn how C# source generators work: partial classes, GeneratedRegex, LoggerMessage, System.Text.Json, incremental generators, Roslyn syntax trees and when to write your own.
- Native AOT, Trimming and Startup Understand Native AOT, IL trimming, ReadyToRun and tiered JIT in .NET: what each does, which C# code breaks (reflection), how to write trim-safe code and when AOT pays off.
- Interop, COM and Native Code Call native C libraries from C#: P/Invoke, marshalling strings and structs, callbacks, function pointers, NativeLibrary, LibraryImport, error codes and the COM basics.
- Pointers, stackalloc and Low-level Memory Go deep on low-level C#: ref locals, stackalloc, unsafe pointers, fixed buffers, InlineArray, the Unsafe and MemoryMarshal classes, endianness and the pitfalls to avoid.
- IL, JIT and Tiered Compilation See what the C# compiler really emits: read IL with a mini disassembler, learn what lambdas, async and foreach become, and how the JIT, tiering, PGO and inlining work.
- C# in Games and Desktop See how C# is used in games (Unity, Godot, MonoGame) and desktop apps (WPF, WinForms, MAUI): game loops, components, coroutines, ECS, GC pitfalls and MVVM, with runnable code.
- INotifyPropertyChanged and MVVM Learn how data binding works in C# - INotifyPropertyChanged, a reusable base class, ObservableCollection, commands and validation - with a tiny binding engine you can run and step through.
- Desktop and Mobile UI: WPF, WinForms, MAUI Compare the C# UI frameworks - WinForms, WPF, WinUI, .NET MAUI, Avalonia and Blazor Hybrid - and learn the shared ideas (UI thread, layout, XAML, binding) with runnable simulations and read-only samples.
- Windows Forms Controls and Properties Learn the core ideas of C# Windows Forms - Form, Label, TextBox and Button properties, event handlers, layout and anchoring - with read-only WinForms code and runnable console stand-ins.
Projects
- Project: Command-Line To-Do App Build a command-line to-do app in C# in four stages: records and LINQ, a command parser and menu loop, JSON persistence behind an interface, and a mini test suite with a fake clock.
- Project: Bank Account System Build a bank in C# in four stages: decimal money and custom exceptions, account classes and events, atomic transfers behind one lock, and an audit log you can replay to prove the books balance.
- Project: Inventory REST API Build an inventory REST API with ASP.NET Core minimal APIs in four stages: endpoints, dependency injection with validation, filters and problem details, then an automated HttpClient test suite.
- Project: Text Adventure Engine Build a text adventure engine in C# in four stages: immutable game state with records, a list-pattern command parser, a pure step function with locked doors and darkness, then undo and tests.
- Project: Log Analyzer Build a log analyzer in C# in four stages: a regex line parser, LINQ reports on thousands of entries, a zero-copy span parser, and a streaming pipeline for large and gzipped files.
- Project: Background Job Queue Build a background job queue in C# in four stages: a bounded Channel with backpressure, retries with exponential backoff, a BackgroundService worker pool, and timeouts, shutdown and tests.
- Project: Library Management System Build a library system in C# in three stages: books and members as classes with rules, borrowing and returning with fines, LINQ reports, and a console menu that runs a script of commands.
- Project: Console Calculator Build an expression calculator in C# in three stages: a tokenizer, a recursive-descent parser with precedence, parentheses and functions, and clear error messages checked by a table of tests.
Practice and Review
- C# Cheat Sheet A one-page C# 14 cheat sheet with tables for syntax, types, collections, LINQ, async and modern idioms, plus runnable snippets you can edit and test.
- Practice Problems: Fundamentals Fifteen graded C# problems on types, control flow, strings, methods and collections. Every problem has a hint and a full solution with tests you can run.
- Practice Problems: OOP, LINQ and Async Fifteen graded C# problems on classes, records, interfaces, events, generics, LINQ and async code, each with a hint and a complete runnable solution.
- Data Structures from Scratch in C# Build a singly linked list and a binary search tree from scratch in C#, then solve classic array problems - rotation, duplicate removal and binary search in a rotated array - with tested code.
- C# Interview Questions and Answers Fifty C# interview questions with concise answers and runnable examples: CLR, value vs reference types, GC, generics, LINQ, async, DI and ASP.NET Core.