← C# Programming learning pathC# Programming · Module 3 of 10
Control flow and methods
Make decisions, loop and organise code into methods.
📖 Key ideas
- if/else, switch and switch expressions.
- Loops: for, foreach, while, do-while.
- Methods: static int Add(int a, int b) => a + b;
- Optional and named parameters.
- out and ref pass variables by reference.
💡 Real-life example: Methods are recipes: write once, cook many times with different ingredients.
foreachLoops over a collection
switch expressionConcise switch returning a value
MethodNamed reusable code block
out parameterReturns extra values via argument