Excellent — here’s **Step B: the Coursebook text**.
This is laid out so that you can save it as `Coursebook.md` and export it directly to PDF from Obsidian or VS Code using a Markdown-to-PDF extension or `pandoc --standalone`.
It’s condensed for readability and printing (about 25 pages once exported) while keeping every code block intact.
---
# 📘 C# MASTERCLASS — COMPLETE COURSEBOOK
_Technical Instructor Edition • Visual Studio Code / .NET 8_
---
## PHASE 1 – FOUNDATIONS OF C#
### Lesson 1 – The First Line
**Topics:** structure of a C# program, Console I/O
```csharp
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, Genius!");
}
}
```
- `using System;` imports base namespace.
- `Main()` is the entry point.
**Project:** _Hello Genius App_ – prompt for a name and greet user.
---
### Lesson 2 – Variables of Power
**Topics:** types, operators, casting
```csharp
int a = 10;
double b = 3;
double r = a / b;
Console.WriteLine(r);
```
**Project:** Unit Converter – convert kilometres to miles.
---
### Lesson 3 – Logic and Flow
**Topics:** conditionals, loops
```csharp
for (int i = 0; i < 5; i++)
Console.WriteLine(i);
```
**Project:** Number Guessing Game – loop until correct guess.
---
### Lesson 4 – Debugging Like a Detective
Use breakpoints, watch variables, inspect call stack.
**Exercise:** fix `NullReferenceException` and `IndexOutOfRangeException`.
---
### Lesson 5 – Collections and LINQ
**Topics:** arrays, lists, dictionaries, LINQ
```csharp
var grades = new Dictionary<string,int>{{"Ava", 95},{"Ben", 88}};
var top = from g in grades where g.Value > 90 select g;
```
**Project:** Student Manager – CRUD in-memory records.
---
## PHASE 2 – OBJECT POWER & ARCHITECTURE
### Lesson 6 – The Art of Objects
**Topics:** classes, fields, properties, constructors
```csharp
class Player
{
public string Name { get; set; }
public int HP { get; private set; } = 100;
public void TakeDamage(int a) => HP = Math.Max(0, HP − a);
}
```
**Project:** RPG Classes.
---
### Lesson 7 – Inheritance and Interfaces
```csharp
interface IFlyable { void Fly(); }
class Airplane : IFlyable { public void Fly()=>Console.WriteLine("Soars."); }
```
**Project:** Vehicle Factory with `Drive()` and `Fly()`.
---
### Lesson 8 – Design Patterns that Think
**Patterns:** Factory, Strategy, Observer
**Project:** Stock Market Notifier with event subscriptions.
---
### Lesson 9 – Clean Code & Dependency Injection
**Principles:** SOLID, DI for loose coupling
```csharp
interface INotifier{void Notify(string msg);}
class OrderProcessor
{
readonly INotifier _notifier;
public OrderProcessor(INotifier n)=>_notifier=n;
public void Process()=>_notifier.Notify("Done");
}
```
**Project:** Plugin-Based Calculator.
---
## PHASE 3 – THE REAL WORLD
### Lesson 10 – Files & APIs
**Topics:** File I/O, JSON, HTTP
```csharp
File.WriteAllText("notes.txt","Learning C#");
string t = File.ReadAllText("notes.txt");
Console.WriteLine(t);
```
**Project:** Weather Dashboard – API call and JSON parse.
---
### Lesson 11 – Databases with EF Core
**Topics:** ORM, DbContext, LINQ queries
```csharp
class TaskItem{public int Id{get;set;}public string Title{get;set;}}
class Ctx:DbContext
{
public DbSet<TaskItem> Tasks {get;set;}
protected override void OnConfiguring(DbContextOptionsBuilder o)=>
o.UseSqlite("Data Source=tasks.db");
}
```
**Project:** Task Tracker DB.
---
### Lesson 12 – GUI & Web Apps
**Minimal API**
```csharp
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", ()=> "Hello Web!");
app.Run();
```
**Project:** To-Do Web App with EF Core.
---
## PHASE 4 – GENIUS LEVEL
### Lesson 13 – Async & Threading
**Topics:** Tasks, await, parallel loops
```csharp
async Task<int> DelaySum(int n){await Task.Delay(1000);return n;}
var r = await Task.WhenAll(DelaySum(1),DelaySum(2));
```
**Project:** Concurrent Web Scraper.
---
### Lesson 14 – Reflection & Generics
Inspect metadata and build generic types.
```csharp
class Box<T>{public T Value{get;set;}public Box(T v)=>Value=v;}
```
**Project:** Simple IoC Container.
---
### Lesson 15 – Capstone Project
Integrate everything into one major application
_(choose Desktop, Web, Game, or Automation)_.
---
## PHASE 5 – THE DEVELOPER’S MIND
### Lesson 16 – Git & Version Control
Key commands: `init`, `add`, `commit`, `branch`, `merge`, `push`.
**Project:** Portfolio Repo.
---
### Lesson 17 – Testing & TDD
**xUnit Example**
```csharp
[Fact]
public void Add_ReturnsSum()=>Assert.Equal(4,new Calc().Add(2,2));
```
**Project:** Student Manager Tests.
---
### Lesson 18 – Performance & Profiling
Use `Stopwatch` and BenchmarkDotNet to measure code.
**Project:** Optimise Web Scraper.
---
### Lesson 19 – Deployment & Documentation
`dotnet publish -c Release -r win-x64 --self-contained true`
Add XML doc comments and GitHub Actions for CI.
**Project:** Deploy Capstone Release.
---
## 📖 Completion Summary
You can now:
- Write and debug C# code
- Apply OOP and design patterns
- Connect to APIs and databases
- Use async operations
- Test, profile and deploy apps
> “Code is communication between minds through machines.”
---
Save this file as `Coursebook.md` and export to PDF.
You now have a readable textbook companion for your lessons.
---
Next I’ll deliver **Step C – Project Templates Pack**: a set of starter `Program.cs` files and folder layouts for every mini-project.
Ready for me to output those now?