Lumenary CS · Programming languages
C#
A modern, statically typed language for the .NET platform, from a first file-based program to async services, LINQ and the tools professionals use every day.
C# (say "C sharp") is a general-purpose, statically typed language created at Microsoft and first shown in 2000. It runs on .NET, a free, open-source and cross-platform runtime, and it is used for web services and APIs with ASP.NET Core, cloud and enterprise systems, desktop applications, developer tools, and games, most famously through the Unity engine. It began as an object-oriented language in the family of C++ and Java and has grown, release by release, into one that also leans on functional ideas: records, pattern matching, LINQ and immutable data.
This course is for anyone who has finished the Start level of Lumenary CS or has equivalent experience: you know what a variable, a loop and a function are, in any language. It goes from installing the .NET SDK and running a one-file program to types, classes and records, generics, nullable reference types, LINQ, exceptions, async code, memory and performance, and the ecosystem of NuGet packages, tests and formatters, ending with a complete program written the way a professional team would write it. It teaches C# 14 on .NET 10, the long-term-support release.
To run the examples, install the .NET 10 SDK from the official download page (Windows, macOS and Linux) and run any single file with dotnet run hello.cs. Microsoft does not offer a standalone online playground for C#; community sites such as SharpLab and .NET Fiddle let you try short snippets in a browser. Every complete program in these lessons was compiled and run with the .NET 10 SDK, and the output shown is the output it printed.
- Chloe · The Designer
“Why is the language built this way?” - Margaret · The Profiler
“What does it print, and what does it cost?” - Gideon · The Language Lawyer
“What exactly does the language guarantee?”
Foundations · 3 lessons
The language and its toolchain
Install .NET, run your first file-based programs, and learn C#'s types, operators, control flow, methods and everyday collections.
- 1First steps with C# and .NETWhere C# came from, what .NET is, and your first programs as single files and as projects. 50 min
- 2Types, operators and control flowNumbers that are exact and numbers that are not, text, conversions, and the statements that decide and repeat. 55 min
- 3Methods, arrays and collectionsPackaging logic into methods, passing data in and out, and the standard collections every C# program leans on. 55 min
Practice · 4 lessons
Modelling and querying data
Design types with classes, structs, records, properties, interfaces and generics, make null safe with nullable reference types and pattern matching, and query data with LINQ.
- 4Classes, structs, records and propertiesDefining your own types, protecting their invariants, and choosing between reference and value semantics. 60 min
- 5Interfaces and genericsWriting code against contracts instead of concrete classes, and writing it once for many types. 60 min
- 6Nullable reference types and pattern matchingMaking "no value" visible in the type system, and asking precise questions about the shape of data. 60 min
- 7LINQ: lambdas and queriesFunctions as values, and a small vocabulary of operators that filters, reshapes, groups and joins any sequence. 60 min
Professional · 3 lessons
Production C#
Handle failure with exceptions and deterministic cleanup, write asynchronous and allocation-aware code, and work with NuGet, ASP.NET Core, tests and analyzers on a complete project.
- 8Exceptions and resource cleanupHow .NET reports failure, how to handle it where you can do something useful, and how to release resources no matter what. 55 min
- 9Async, tasks and memoryWaiting without blocking, running work in parallel safely, and how .NET's memory model shapes fast code. 70 min
- 10The ecosystem and a complete projectNuGet, ASP.NET Core, testing with xUnit, formatters and analyzers, and a small program written the way a team would write it. 70 min
Further reading and resources
- .NET · MicrosoftThe platform's home page, with downloads of the SDK for every operating system.
- C# documentation · MicrosoftThe official guide, tutorials and language reference.
- C# language specification · Microsoft and Ecma TC49-TG2The working draft of the standard, with links to the feature specifications of newer versions.
- ECMA-334: C# language specification · Ecma InternationalThe published standard; its first edition appeared in December 2001.
- dotnet/csharplangWhere the language is designed in the open: proposals, discussions and design-meeting notes.
- Download .NET · MicrosoftThe official installers for the SDK and runtimes.
- SharpLabA community playground that runs C# in the browser and shows what the compiler turns it into.