C# & .NET for Mere Mortals
A program begins as a pile of small questions — what is in stock, what is it worth, what is about to run out — and ends as a tool that answers them the same way every time. Getting there in most languages means assembling the toolkit first. C# takes the opposite bet: one download brings the compiler, the library and the command that drives them, and the same afternoon's work runs identically on Windows, Linux and macOS.
This guide takes Microsoft's language — C#, pronounced "see sharp" — and the platform under it, .NET, from an empty machine to a finished, tested, published program, proving each step in a small lab as it goes. The program is a stock reporter: it reads an invented warehouse CSV file and prints totals, values by category, and low-stock warnings, with every sum checked twice — once by a test suite, once by a completely different tool.
What the lab proved
Everything below was run for real; the transcripts live in
csharp-lab/ beside this guide.
- The .NET SDK 10.0.403 (the current LTS channel) installed into the lab's own folder — by hand, after the official install script's extraction failed twice with an error the disk did not deserve; the guide keeps the failure and the workaround side by side (t00, t01).
- A console program,
StockReport, built from the standard template and grown into three small types — arecordfor the stock line, a parser, and a summary class that answers questions about the whole file with LINQ (t02, t03). - Its figures — 14 lines, 3,279 units, 19,021.35 of stock value — reproduced exactly by an independent Python cross-check that shares no code with it (t04).
- A test project in xUnit whose restore first failed on a
network timeout and then succeeded on retry (t05); whose
dotnet testrun was defeated by the build machine's loopback limits, so the suite was executed by xUnit's own console runner instead — where it promptly caught a mis-added expectation in one of its own tests, was fixed, and ran six of six green (t06, t07). - The program published as a standalone folder and run from somewhere else entirely, away from its project (t08); its failure modes — a missing file, a malformed row — kept verbatim (t09).
- As a stretch goal, the same code served as a small ASP.NET Core web API on loopback, answering curl with the report's figures as JSON (t10).
Described but not run — Windows-only .NET Framework, Visual Studio, the GUI and mobile frameworks (WPF, WinForms, MAUI, Blazor), and cloud deployment — and labelled as such wherever they appear, starting with the Limits chapter.
The chapters
- What C# and .NET Are — the language and the platform, and which is which
- The Moving Parts — SDK, runtime, NuGet, the compiler, and the one command that drives them
- Installing the .NET SDK — four routes, and the lab's eventful one
- Your First Checks — proving the installation is whole before trusting it
- Your First Program — a project from the template, read line by line
- The Language Core — types, text, loops, methods, and null taken seriously
- Organising the Program — classes and records, one job each
- Working with Data — the stock file, LINQ, and a second tool checking the sums
- Testing Your Code — xUnit, a failed restore, and what a green run is worth
- Publishing Your App — the folder you hand to someone else
- Recipes — the report bent to new questions
- The Neighbours — F#, PowerShell, Java, Go, Rust, and the Windows elder
- Limits — what the lab did not run, and what C# is not for
- Troubleshooting — the failures this guide actually met, in order
- Glossary — the terms, collected
What you need
A machine that can take a ~240 MB download and a terminal. No account, no licence fee, no IDE: the SDK is free and open source, and every step here is a command you can watch. The lab ran on a small shared Linux machine; timings there are honest but not promises.
Part of the series
This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.
Related guides:
License
The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.