Course · 34 lessons

C# Foundations

Write a small program, read types, and fix errors.

  1. First program

    A console program starts in Program.cs and runs from the top.

    Start · 6 min
  2. Variables

    var stores a value under a name you can use again.

    Values · 7 min
  3. Decimal

    decimal keeps money exact. The m suffix marks a decimal literal.

    Numbers · 8 min
  4. Strings

    Text lives in quotes. A name without quotes is a variable.

    Text · 7 min
  5. Conditions

    A comparison is true or false, and if picks a path from that.

    Logic · 8 min
  6. Loops

    A for loop repeats while its condition stays true.

    Logic · 9 min
  7. Arrays

    new[] stores values in order, and the first index is 0.

    Methods & logic · 8 min
  8. Lists

    A list starts empty and grows when you add items.

    Methods & logic · 8 min
  9. Methods

    A method names a calculation so another line can call it.

    Methods & logic · 8 min
  10. Parameters

    A parameter is the name a caller fills in.

    Methods & logic · 8 min
  11. Console input

    ReadLine returns the next prepared line, then null.

    Input · 7 min
  12. Diagnostics

    Check reports a missing name. Run does not invent a value.

    Problems · 8 min
  13. Names

    One name, one meaning in the same block.

    Review · 6 min
  14. Comments

    A comment is for a person. The compiler skips it.

    Review · 5 min
  15. Several files

    A project can hold a type in one file and the entry in another.

    Projects · 8 min
  16. Snapshots

    Run freezes the text you had at that moment.

    Run · 6 min
  17. A small bill

    Add a few decimal amounts and print the total.

    Practice · 9 min
  18. Review

    You can read a small program, change one value, and run it again.

    Review · 10 min
  19. Quotients, remainders, and negative values

    Use integer arithmetic to split a quantity and reason about its remainder.

    Applied foundations · 15 min
  20. Boolean guards and short-circuit evaluation

    Order conditions so later expressions are safe to evaluate.

    Applied foundations · 15 min
  21. Switch expressions with explicit boundaries

    Turn a small decision table into an exhaustive expression.

    Applied foundations · 15 min
  22. Nullable value types and intentional defaults

    Represent a missing measurement without confusing it with zero.

    Applied foundations · 15 min
  23. Tuple results and deconstruction

    Return related results from one calculation without parallel variables.

    Applied foundations · 15 min
  24. Named arguments and optional parameters

    Make call sites readable without hiding important choices.

    Applied foundations · 15 min
  25. Parameter arrays and empty input

    Design a small aggregate function that accepts zero or many values.

    Applied foundations · 15 min
  26. The Try pattern and out results

    Separate successful parsing from the value produced by a parser.

    Applied foundations · 15 min
  27. Passing by value and passing by reference

    Trace which variable a method is allowed to replace.

    Applied foundations · 15 min
  28. Array aliases and independent copies

    Choose whether a second variable shares or copies an array.

    Applied foundations · 15 min
  29. Indices, ranges, and slice boundaries

    Read from the end and create slices with an exclusive upper bound.

    Applied foundations · 15 min
  30. Nested loops for rows and columns

    Keep coordinates and loop bounds explicit while processing a small matrix.

    Applied foundations · 15 min
  31. Continue, break, and a processing sentinel

    Distinguish skipping one item from ending a whole loop.

    Applied foundations · 15 min
  32. Flags enums and independent capabilities

    Represent combinations of small, independent options with bits.

    Applied foundations · 15 min
  33. String positions and explicit comparison rules

    Search and extract machine-readable text without culture-dependent surprises.

    Applied foundations · 15 min
  34. A validated stock summary

    Combine parsing, guards, calculations, and reporting in one small program.

    Applied foundations · 15 min