1. Introduction
The PDF in the document is HERE.
The code in this document is HERE.
This document is a product of Anthropic’s AI Claude. It is a rewrite, for C# 14 and the .NET 10 platform, of the course “Learning C# Version 3.0 with the .NET 3.5 framework”, written by Serge Tahé in May 2008. It retains the course outline, examples, and central theme, while updating the language, libraries, and tools:
- the 2008 course used C# 3.0 and the .NET 3.5 framework on Windows with Visual C# 2008 Express. Since then, C# has seen eleven major versions (from C# 4.0 in 2010 to C# 14 in 2025), and the .NET platform has been completely rewritten: it is now open-source, cross-platform (Windows, Linux, macOS), and released annually. This document uses .NET 10 (November 2025, long-term support version) and C# 14;
- the chapter on Windows Forms graphical user interfaces has been removed: today, business applications are most often written with web interfaces. The “User Events” chapter, which followed it, has been reworked into a chapter on delegates, lambda expressions, and events, without forms;
- Two chapters are new: asynchronous programming ([Task] tasks and the [async] / [await], introduced in 2012 with C# 5) and Entity Framework Core, the object-relational mapping tool for .NET. The chapter on commonly used .NET classes now covers LINQ (the 2008 course explicitly stated that it did not cover this);
- the tools have changed: the [VS Code] editor (or the IDE and [Visual Studio 2026]) and the [dotnet] command replace Visual C# 2008 Express; the [MSTest] testing framework replaces [NUnit 2]; the dependency injection provided by [Microsoft.Extensions.DependencyInjection] replaces [Spring.NET]; the DBMS [MySQL] (provided by [Laragon]) and the [MySqlConnector] connector replace SQL Server 2005 Express; the [HttpClient] class replaces [WebClient] and [WebRequest], which have been deprecated; the REST / JSON web services written with ASP.NET Core replace the SOAP and [ASMX] web services;
- anything that has become obsolete has been removed or marked as such, and each chapter presents the latest features of the language and platform as of the time of writing.
This document is not a comprehensive course. Like the 2008 edition, it is intended for readers who already have programming experience and want to learn the basics of C#. It uses examples: more than two hundred programs (nearly three hundred C# files), most of them short, with line-by-line comments.
1.1. C# and .NET from 2002 to 2026
C# was released in February 2002, alongside Microsoft’s .NET 1.0 platform, to which it is tied. The .NET platform is a runtime environment similar to the Java Virtual Machine: the compilers for the .NET languages (C#, F#, VB.NET) generate intermediate code (IL, “Intermediate Language”) that the .NET virtual machine (the CLR, “Common Language Runtime”) compiles on the fly into machine code. All classes on the platform are available to all .NET languages.
In 2008, the course stated that .NET ran only on Windows and that the Mono project allowed it to be used, to a limited extent, on Unix and Linux. The situation has changed significantly:
- 2016: .NET Core 1.0. Microsoft has released a new implementation of .NET, which is open source (MIT license, code available on GitHub) and cross-platform: Windows, Linux, and macOS. The old “.NET” framework (.NET Framework 4.x) remains supported for legacy Windows applications but is no longer being developed;
- 2020: .NET 5. .NET Core becomes simply “.NET”: a single platform for all uses (console, web, desktop, mobile, cloud);
- Since 2020: A new version of .NET is released every year in November. Even-numbered versions (.NET 6, 8, 10) have extended support (LTS, three years); odd-numbered versions (.NET 7, 9) have standard support (STS: eighteen months, extended to two years starting with .NET 9). Each version of .NET introduces a new version of C#;
- November 2025: .NET 10 (LTS) and C# 14, which are used in this document. .NET 10 is supported through November 2028.
The 2008 course also noted that in 2002, C# was largely a copy of Java and that it was easy to switch between the two, but that the two languages had since developed their own distinct characteristics. The gap has widened: Over the course of its various versions, C# has incorporated concepts from functional languages (lambda expressions, LINQ, pattern matching, records, immutable types), asynchronous programming ([async] / [await], which JavaScript, Python, and Rust have since adopted), and a type system that detects null references at compile time.
The following table summarizes the main new features of the language since C# 3.0 and indicates the chapter of this document where they are discussed:
Version | Year | Major New Features | Chapter |
C# 4.0 | 2010 | named and optional parameters (the [dynamic] type and generic variance, which also appeared in C# 4, are not covered) | 3 |
C# 5 | 2012 | Asynchronous methods [async] / [await] | 9 |
C# 6 | 2015 | interpolated strings [$"..."], [nameof], operator [?.], exception filters [when], expression-bodied members | 3, 4 |
C# 7.0–7.3 | 2017–2018 | tuples and destructuring, [out var], local functions, pattern matching, binary literals and separators [_], parameters [in] | 3, 4 |
C# 8 | 2019 | nullable reference types, expressions [switch], indexes [^1], and ranges [1..3], [??=], declarations [using], default interface methods, asynchronous streams [await foreach] | 3 through 9 |
C# 9 | 2020 | high-level statements, [record], properties [init], [new()] to target type, relational and logical patterns | 3, 4 |
C# 10 | 2021 | [global using], file-scope namespaces, [record struct], natural type of lambdas | 3, 4, 7 |
C# 11 | 2022 | raw strings ["""], members [required], list patterns, abstract static interface members | 3, 4, 5, 12 |
C# 12 | 2023 | primary constructors, collection expressions [1, 2, 3], aliases for any type, default lambda parameters | 3–7 |
C# 13 | 2024 | collections [params], type [System.Threading.Lock] | 3, 8 |
C# 14 | 2025 | extension members ([extension] blocks), [field] keyword, [a?.B = x] conditional assignment, user-defined compound assignment operators, untyped lambda parameter modifiers | 4, 7 |
On the platform side, the new features introduced include: the [dotnet] command and single-file applications (.NET 10), the [.slnx] solution format, LINQ, modern generic collections, [System.Text.Json], compile-time-generated regular expressions, dependency injection, tasks and the parallel library, channels [Channel<T>], [HttpClient], ASP.NET Core and Entity Framework Core.
1.2. Document Contents
This document includes the following chapters:
- Chapter 2: Setting up the development environment (.NET 10 SDK, VS Code, or Visual Studio; the [dotnet] command);
- Chapter 3: Language Fundamentals (types, operators, control statements, exceptions, enumerations, parameter passing, tuples);
- Chapter 4: Classes, Structures, Interfaces, Inheritance, Generics, Records, Extension Members;
- Chapter 5: Commonly Used .NET Classes: Strings, Arrays, Collections, LINQ, Text and Binary Files, JSON, Regular Expressions;
- Chapter 6: Layered architectures, unit testing with MSTest, and dependency injection;
- Chapter 7: Delegates, lambda expressions, and events;
- Chapter 8: Execution threads and synchronization;
- Chapter 9: Asynchronous Programming;
- Chapter 10: Database Access with ADO.NET;
- Chapter 11: Entity Framework Core;
- Chapter 12: Web Programming (TCP/IP, TCP clients and servers, HTTP with [HttpClient]);
- Chapter 13: Web Services with ASP.NET Core;
- Chapter 14: Going Further;
- Appendices: Installing Laragon and MySQL.
1.3. The Common Thread: Tax Calculation
As in 2008, the same problem is revisited throughout the document: calculating the income tax for a taxpayer who has only their salary to report. The tax bracket used is that of the original course (2003 income): it is no longer current, but it suffices for our purpose, which is to write the same application in several different ways. It is implemented in nine versions:
Version | Chapter | Content |
1 | 3 | A single program: validated input, calculation, display |
2 | 4 | Classes and interfaces: [TaxBracket], [ITax], [AbstractTax], [HardwiredTax] |
3 | 5 | calculation data read from a text file or a JSON file |
4 | 6 | A layered architecture ([dao], [business], [ui]) within a single project |
5 | 6 | One library per layer, unit tests, and integration of layers via dependency injection |
6 | 10 | A [dao] layer that reads data from a MySQL database using ADO.NET |
7 | 11 | a [dao] layer written with Entity Framework Core |
8 | 12 | A TCP tax calculation server and its client |
9 | 13 | a REST web service for tax calculation, a console client, and a web client |
Starting with version 5, subsequent versions reuse the layers from version 5 and replace only the layer that has changed: this is the whole point of the layered architecture presented in Chapter 6.
1.4. Examples
The code in this document is organized in a single folder named [csharp-oct-2026], with one subfolder per chapter:
The small programs are single-file applications: a single file named [.cs], executed by the command [dotnet run file.cs] (Chapter 2). Multi-file programs are projects ([.csproj]) grouped into a solution ([.slnx]) by chapter.
All programs in this document were compiled without errors or warnings using .NET 10 SDK, and then executed. The results reproduced in the document are those from these executions. The results of Chapter 3 were obtained in the French locale (fr-FR), as on a French Windows workstation: real numbers are displayed with a decimal comma, and dates are in French. The later chapters were run in the American English locale (en-US): decimal point, comma as the thousands separator, dates in the month/day/year format. Two notes:
- error messages from the .NET platform (exception messages) are in English: .NET does not provide French translations for these messages;
- the examples were run on Linux. For the most part, this makes no difference: .NET is cross-platform. The few differences (file paths with / instead of \, line endings) are noted where they occur.
The results of multithreaded, asynchronous, or network programs, as well as the measured execution times, may vary from one run to another: the comments focus on what is reproducible.
1.5. Sources
The 2008 course cited the books that helped in writing it: “Professional C# Programming” (Wrox), “C# and .NET” by Gérard Leblanc (Eyrolles), and “C# 3.0 in a Nutshell” by Joseph and Ben Albahari (O’Reilly), “one of the best programming books I’ve ever read.” For the 2026 edition, the primary sources are:
- Microsoft’s official documentation: https://learn.microsoft.com/en-us/dotnet/ (C# language guide, reference for the .NET APIs, ASP.NET Core, Entity Framework Core);
- the what’s new page for each version of C#: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/;
- the successive editions of “C# in a Nutshell” by Joseph Albahari (O’Reilly), which remain an excellent reference.