Module 03 of 12

Control Flow & Methods

Lessons

About This Module

Programs become useful when they can make decisions, repeat work, and reuse logic. This module covers the three tools that do that in C#: branching with if/else and switch, looping over data, and packaging code into methods you can call from anywhere.

It starts with if/else statements and while loops, then moves to the more concise switch expressions found in modern C#. From there you'll work with arrays and for/foreach loops to process collections of values, and finish with extension methods, a practical look at how methods are defined, called, and used to add behaviour to types you already have.

Watch the lessons in order, then continue on to Object-Oriented Programming.

Lessons

4 videos
01

C# for Beginners Part 2 - Learn how to write an 'if-else' statement and a 'while' loop

Layla Porter introduces conditional logic, running different blocks of code depending on whether a condition is true or false, and then repeats work with a while loop.

02

Switch Expressions In C#

Tim Corey rewrites a chain of if-else statements as a switch expression, showing how modern C# gets the same result with cleaner syntax and fewer lines.

03

C# for Beginners Part 5 - Arrays and More Loops

Layla Porter explains arrays as fixed-length collections and introduces more looping techniques for working through the data they hold.

04

How To Create Extension Methods in C#

Tim Corey defines a method in a static class and calls it as though it belonged to the type it extends, a practical view of how methods are written and called.