courses / c# / level 2

level 2 · medium

intermediate
c#.

Build useful C# programs with lists, dictionaries, your own classes, LINQ, exceptions and files.

  • 28 lessons
  • 7 units
  • 4 h 38 m in all
  • £0, for good

what’s inside.

For people who finished Level 1, or can already write small programs with variables, decisions, loops and functions.

C# Level 2 picks up where Level 1 ended and puts your skills to work on small, real programs. In 28 lessons you master lists and dictionaries, design classes, interfaces, enums and records, question your data with LINQ, handle problems with exceptions and null, and save your work in files. It ends with a level check: a budget tracker you drive with typed commands, which keeps its entries safe in a file.

every lesson goes the same way.

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

unit 1

Lists and dictionaries

Keep as many things as you like, and look them up by name.

4 lessons · 38 min

  1. A list that grows9 minMake a list you can keep adding to.
  2. Changing a list9 minSwap, squeeze in, take out and sort items.
  3. Look it up with a dictionary10 minStore pairs and find a value by its name.
  4. Tallies and loops over a dictionary10 minCount how often things turn up and list every pair.

unit 2

Your own classes

Design your own kinds of thing, with data and actions inside.

4 lessons · 41 min

  1. A class is a blueprint10 minDesign your own type and build objects from it.
  2. Constructors10 minFill in a new object the moment it is built.
  3. Methods and ToString10 minGive objects actions, and decide how they print.
  4. Properties guard your data11 minLet everyone read a value, but only the class change it.

unit 3

Families of classes

Share code between related classes and promise what they can do.

4 lessons · 41 min

  1. Inheritance10 minBuild a new class on top of one you already have.
  2. virtual and override10 minLet each kind of object answer the same call its own way.
  3. Interfaces10 minPromise what a class can do, whatever its family.
  4. Sort your own objects11 minTeach Sort how to put your objects in order.

unit 4

Choices and records

Name a fixed set of choices, branch on them and keep data tidy.

4 lessons · 37 min

  1. Enums9 minName every allowed choice, so typos cannot creep in.
  2. switch9 minJump straight to the matching choice.
  3. Records10 minWrite a whole data class in a single line.
  4. Copies with with9 minMake a changed copy of a record and keep the original.

unit 5

Ask your data questions

Filter, reshape, sort and sum a list, each in a single line.

4 lessons · 40 min

  1. Filter with Where10 minKeep only the items that pass a test.
  2. Reshape with Select10 minTurn every item into something new.
  3. Sort with OrderBy10 minSort by anything you like, in either direction.
  4. Count, Sum, Average and Max10 minGet one answer from a whole list.

unit 6

When things go wrong

Catch problems, throw your own and keep your program running.

4 lessons · 40 min

  1. Catching a problem10 minHandle an exception and keep the program going.
  2. More catches and finally10 minHandle each kind of problem, and always tidy up.
  3. Throwing a problem10 minRefuse bad values by throwing an exception yourself.
  4. Your own exception class10 minName your app's problems so callers can catch them.

unit 7

Save your work

Handle missing values, tidy your output and keep it in files.

4 lessons · 41 min

  1. When nothing is there: null10 minReach into objects safely, even when they are missing.
  2. Tidy numbers and columns10 minShow money properly and line up your columns.
  3. Writing and reading a file10 minKeep text safe after the program ends.
  4. One line per record11 minAdd to a file line by line, and read it back in parts.
end of level 2 level check: a budget tracker Build one small project with everything from this level. Pass it and your face levels up. see the check

next, level 3

advanced
c#.

Write C# like a professional: generics, delegates, LINQ, patterns, async code, thread safety and tests.

see level 3