Learn C#
Short lessons where every snippet runs — press the button under any example, see real output. Start at the top; each lesson links to practice problems that use what you just learned.
Getting started
-
Lesson 1 — Hello World
WriteLine, comments, string interpolation, and the two shapes of a C# program (top-level statements vs class Program + Main).
-
Lesson 2 — Variables & the core types
int, double, string, bool, char — plus the three traps: integer division, overflow wrap, and floating-point surprise.
-
Lesson 3 — Making decisions
if/else chains, && and ||, switch with stacked labels, the ternary — and the golden rule that conditions are always bool.
-
Lesson 4 — Loops
for, while, do-while and foreach; the accumulator pattern, break/continue, nested loops, and which loop to reach for.
-
Lesson 5 — Methods
Parameters, return values, default arguments, out parameters and recursion — naming a recipe so you can reuse it.
-
Lesson 6 — Classes & objects
Fields, constructors, methods, auto-properties, static vs instance, and
this. -
Lesson 7 — Inheritance & interfaces
virtual/override, base constructors and calls, interfaces as contracts, is/as type tests.
-
Lesson 8 — Collections
Arrays vs List<T> vs Dictionary<K,V> — when to use each, and the tools on each.
-
Lesson 9 — Exceptions
try/catch/finally, the exception family tree, throwing your own, TryParse-vs-catch.
Where next?
The full beginner course is here. Deepen it with the error decoder (12 compiler errors, live), the articles on the classic traps, and the graded problem set.