Free through lesson 3

C# Intro Course

From setting up .NET 10 SDK through types, control flow, classes and interfaces, records and pattern matching, LINQ, async/await and exception handling, NuGet and JSON, xUnit testing, and ASP.NET Core Minimal API. Across 50 lessons, you'll build applications in C# and learn how to bring that C# into Unity. Every line of code and output has been run live with .NET 10 SDK (C# 14) and verified with tests.

Curriculum

All 50 lessons are divided into 7 chapters. It's best to work through chapter 1 first, but you can also skip around to topics that interest you. Note: You can't run code in the browser, so install .NET 10 SDK on your machine and run dotnet run and dotnet test. Lessons 46–50 are written for Unity's conditions (C# 9 and .NET Standard 2.1), not Unity Editor, so we build and test a library in .NET under the same constraints.

Chapter 1 — Getting Started with C# (lessons 1–7)

Install .NET 10 SDK and run C# in both a single-file program and a project. Learn variables and types, value types and reference types, strings and numbers, conditional branching, loops and arrays — all verified with tests.

1

What Is C#? (Run in One File)

Sort out how C# and .NET relate, run a single-file program with dotnet run hello.cs, and move through a project structure that pairs each program with a test.

Free
2

Setting Up and the dotnet Command

Install .NET 10 SDK, create a project with dotnet new console and run it. Read a .csproj file, pass arguments to dotnet run, use global.json, and run tests.

Free
3

Variables and Types (double and decimal)

Meet var and type inference, common types at a glance. See how double's 0.1 + 0.2 has rounding error and why decimal is for money, see int overflow and checked, and try casting and compile errors.

Free
4

Value Types and Reference Types

Build the same data shape in struct and class, compare assignment, method argument passing, and ==. Learn what ref means and why string is a reference type that acts like a value.

🔒 Basic
5

Strings and Numbers (Format, TryParse, Rounding)

String interpolation width and formatting, currency notation by culture (ja-JP shows ¥ as half-width), raw string literals, Parse and TryParse, and banker's rounding in Math.Round.

🔒 Basic
6

Conditional Branching and switch Expressions

Use if, else if, else to split shipping costs, use a switch expression to turn scores into grades. Solve FizzBuzz with tuples, see the CS8509 warning about forgotten cases, and test edge values.

🔒 Basic
7

Loops and Arrays (Index and Range)

Create arrays with collection expressions, choose between for, foreach, while, and do-while. Use continue and break, index from the end with ^1 and ranges with 1..3, and catch out-of-range errors.

🔒 Basic

Chapter 2 — Methods and Object-Oriented Programming (lessons 8–15)

Start with methods to name your code, then move to classes, properties, and access modifiers. Work through inheritance, polymorphism, interfaces, and abstract classes to call the same method but get different behavior.

8

Methods (out, Tuples, Local Functions)

Return values and parameters, overloading, params, defaults, and named arguments. Choose between out and tuples to return two values, cover recursion and local functions.

🔒 Basic
9

Classes and Objects

Model a bank account with fields, constructor, and methods in one class. See how each object created with new has its own state, learn encapsulation with private, and override ToString.

🔒 Basic
10

Properties and Constructors (field, required)

Use auto-properties, private set, init, required, and computed properties. Try C# 14's field to validate values, and work with primary constructors and this(…).

🔒 Basic
11

Access Modifiers and static

Use public, private, protected, internal to control scope, separate static members from per-object members. Learn const and static readonly, static classes, and InternalsVisibleTo.

🔒 Basic
12

Inheritance

Build a vehicle parent class that Truck and Bicycle inherit. Call the parent constructor with base(…), use protected and sealed. See is to treat children as parents, and object as the root.

🔒 Basic
13

Polymorphism (override and new)

Put Circle, Rectangle, and Square as "shapes" in one array, computing area the same way for each. Learn virtual and override, and how new (hiding) gives different results for the same call.

🔒 Basic
14

Interfaces

Write "take a price, return a discounted price" as a contract in IDiscount; the register knows only the contract. Try default implementations, test fakes, and IComparable<T> for Sort.

🔒 Basic
15

Abstract Classes

An abstract class holds the "heading → body → conclusion" flow, leaving only body for children. See how abstract and virtual differ, use template method, and choose interface vs. abstract class.

🔒 Basic

Chapter 3 — The C# Way (lessons 16–23)

Use C#-specific tools like nullable reference types, records, pattern matching, structs, operator overloading, and extension members. Finish with delegates and lambda expressions, then events to pass code as a value.

16

Nullable Reference Types (?. Assignment)

Learn the difference between string and string?, warnings CS8600 and CS8602 if you forget to check. Use ?., ??, ??=, and C# 14's ?. assignment, then ThrowIfNull and is null to verify.

🔒 Basic
17

record

Create a value-holding type in one line with record. Compare by contents with ==, see contents in ToString, destructure it, use with for a changed copy, and tell record, record struct, class apart.

🔒 Basic
18

Pattern Matching (List Patterns)

Distinguish values with type, when, property, and position patterns. Use C# 11's list patterns to parse commands, apply or/and with relation patterns for seasons and fares, and see why order matters.

🔒 Basic
19

struct

Create immutable value types with readonly struct, returning a new value to change. Learn defaults and size, pass read-only with in, and avoid the pitfall of a List struct copy silently changing.

🔒 Basic
20

Operator Overloading

Add + and * to a vector type so position + 3 * velocity works. Create == and != together for money types (rule CS0216), and try implicit and explicit conversion.

🔒 Basic
21

Extension Methods and Extension Members (C# 14)

Add this to the first parameter to give string Truncate and IsBlank. See it's really a static method, callable on null, and how C# 14's extension block adds extension properties and static members.

🔒 Basic
22

Delegates and Lambda Expressions

Pass the discount rule itself as an argument. Learn delegate types and method groups, write lambda expressions inline, Func and Action, closures that capture outer variables, and multicast with +=.

🔒 Basic
23

Events

When a stock price changes, call registered handlers. Use EventHandler<T>/EventArgs, invoke with ?.Invoke, +=/-= to register, and see event block outside calls (CS0070). Test with Assert.Raises.

🔒 Basic

Chapter 4 — Collections and LINQ (lessons 24–31)

Store data in List and Dictionary, use generics to organize it, and use LINQ to filter, sort, aggregate, and join. Understand deferred evaluation and yield, then build a complete sales report.

24

List and Dictionary

Pick between List, Dictionary, HashSet, Stack, Queue. Hold ToDos in List, count words in Dictionary, check parenthesis matching with Stack. Know TryGetValue and the difference between Add and [ ] =.

🔒 Basic
25

Generics

Turn a type into "an argument to decide later." Use generic classes/methods, where constraints (IComparable<T>, new()), .NET 7's generic math, and one warehouse class reused for books and members.

🔒 Basic
26

LINQ Basics

Filter with Where and reshape with Select on a product list. Choose between method and query syntax, pick First and FirstOrDefault, use Any, All, Count, Distinct, and page with Skip and Take.

🔒 Basic
27

Sorting and Grouping

Sort by highest score, ties broken by reading order. See how kanji names don't sort by reading, use GroupBy for per-group averages, ToDictionary, .NET 9's CountBy/Index, and Chunk for teams.

🔒 Basic
28

Aggregation and Joining

Sum, Average, and MaxBy sales from an order list, then Join/GroupJoin to connect customers. See how unmatched customers differ, try SelectMany, Aggregate, Zip, and why Empty.Average throws.

🔒 Basic
29

Deferred Evaluation

Log call order to see LINQ doesn't run until you pull from it, watching one value flow at a time. See it runs fresh on each pull, ToList() locks it in, and exceptions fire at the pull point.

🔒 Basic
30

Iterators and yield

Write a "return one and pause" method with yield return, taking from an endless Fibonacci sequence via Take. Use yield break, implement IEnumerable<T>, and see the MoveNext/Current behind foreach.

🔒 Basic
31

[Project] Sales Report (Aggregate CSV)

Chapter 4 capstone: read sales CSV into records, then use LINQ for monthly totals, top 3 products, and category share. Report bad rows by line number, and format output with InvariantCulture.

🔒 Basic

Chapter 5 — Async and Exception Handling (lessons 32–38)

Learn how to catch and design exceptions, use using for cleanup, then move to async and await. Handle multiple Tasks, cancellation and timeouts, and async streams.

32

Exception Handling

Split try/catch/finally handling for non-numeric input, division by zero, and out-of-range numbers. Add conditions with when, compare throw; vs. throw e; in stack traces, and see uncaught exceptions.

🔒 Basic
33

Designing Exceptions

As the thrower, how do you report failure? Write your own exception with diagnostic values, use ThrowIf… guard clauses, know the Try pattern for common failures, and wrap while keeping InnerException.

🔒 Basic
34

IDisposable and using

Represent things needing cleanup with IDisposable, using using to guarantee it. Dispose stays safe when called repeatedly, runs even on exceptions, cleans up in reverse order — see StreamWriter write.

🔒 Basic
35

async and await

Boil water while toasting bread with async and Task<T>. Immediate await runs sequentially; creating both Tasks first runs them together, timed to prove it. Tasks start on creation — avoid async void.

🔒 Basic
36

Waiting for Multiple Tasks

Use a fake downloader to handle many Tasks together. See WhenAll's result order and exceptions, use WhenAny to grab the fastest and cancel the rest, and cap concurrency with Parallel.ForEachAsync.

🔒 Basic
37

Cancellation and Timeout

Send "stop" via CancellationTokenSource; the receiver decides to stop via CancellationToken. Set a deadline with CancelAfter, link tokens to tell caller cancellation from timeout, and learn WaitAsync.

🔒 Basic
38

Async Streams

Represent sensor values arriving gradually as IAsyncEnumerable<T>, received with await foreach. Use .NET 10's async LINQ, cancel with WithCancellation, and bridge producer/consumer via Channel.

🔒 Basic

Chapter 6 — Building Apps with .NET (lessons 39–45)

Divide solutions and projects, use NuGet, read and write files and JSON. Write unit tests with xUnit v3 and build an ASP.NET Core Minimal API, testing all the way.

39

Solution and Project Structure

Separate UI from logic into a class library. Connect with dotnet new classlib, add reference, and sln add, organized in .NET 10's default .slnx. Learn namespaces, internal, and how tests reference it.

🔒 Basic
40

NuGet Packages

Pull libraries into .NET via NuGet. Add Humanizer.Core with dotnet add package, verify with dotnet list package, centralize versions in Directory.Packages.props, and know what to check in a package.

🔒 Basic
41

File Input/Output (BOM)

Write diary entries line by line. Use Path.Combine, Directory.CreateDirectory, AppendAllText, ReadLines, and StreamReader, work with temp folders, and see the BOM added by Encoding.UTF8.

🔒 Basic
42

Reading and Writing JSON

Write records to JSON with System.Text.Json. Use web defaults, stringify enums, see Japanese text escape to \uXXXX (fix with Encoder), JsonPropertyName/required, and try JsonNode/source generation.

🔒 Basic
43

Unit Testing (xUnit v3, TimeProvider)

Test coupon expiration via TimeProvider, swapping in a fake clock. Learn Arrange-Act-Assert, per-test rebuilding, Fact/Theory (InlineData, MemberData), Assert.Multiple, Skip, and reading failures.

🔒 Basic
44

ASP.NET Core Minimal API

Build a ToDo Web API with Minimal API. Use Microsoft.NET.Sdk.Web, register with DI, map MapGet/Post/Put/Delete and MapGroup, handle {id:int}, return codes via TypedResults, and verify with curl.

🔒 Basic
45

Testing Minimal API

Test the API inside the test, no server needed. Use .NET 10's AddValidation for attribute checks, swap time via WebApplicationFactory<Program>, and check status/JSON with HttpClient.

🔒 Basic

Chapter 7 — Handing Off to Unity (lessons 46–50)

See how Unity's C# differs from .NET 10 by building a library under Unity's conditions (C# 9 and .NET Standard 2.1). Learn MonoBehaviour, coroutines, and attributes through models, then move to Unity courses.

After you finish all 50 lessons, take what you've built and make a complete game in the Unity Game Dev Intro Course. Membership unlocks all courses.