Skip to main content
๐Ÿ“œ WAYPOINT LESSON

Checkpoint โ€” Delegates & Capture

โญโญ intermediateโณ 20 min read๐Ÿ“ Lesson 97 of 265

Counter factories, capture-debugging, and a callback-driven command router in one graded unit.

The gate

Three functions, one graded unit:

  1. MakeAccumulator(int seed) returns a Func<int, int> that adds its argument to a private running total (starting at seed) and returns the new total. Two accumulators are independent.
  2. SumActions(params Action[] steps) returns an Action that runs every step in order โ€” twice if a step appears twice, skipping nulls safely.
  3. Route(string command, int value) โ€” a table-driven router over registered commands (register via RegisterCommand(name, Func<int,int>)); unknown command returns -1, known ones apply their function.

Capture semantics decide all three.