Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Comments · Lesson 19 of 27

Why Comments Matter

A free lesson from Swipe Coding · C#, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
Comments won't run, but they might just save future-you a headache. 📝

A comment is a note in the code that the C# compiler completely ignores. Comments never change what a program does — they exist purely for humans who read the code: yourself a few weeks from now, or teammates who look at it later.

class Program
{
    static void Main()
    {
        // This line greets the user
        Console.WriteLine("Hello, World!");
    }
}
The compiler skips the line with the comment entirely — it has no effect whatsoever on the program.
True or false

Comments are executed by the C# compiler like normal code.

🤖
A comment that just repeats the code isn't pulling its weight. 📝

Code you write today, you often don't look at again until weeks or months later — and by then you may have forgotten why you wrote certain lines the way you did. A good comment immediately explains what's going on, without forcing you to re-read and re-think the entire block of code.

// TODO: Add an evening greeting later
Console.WriteLine("Good morning!");
A TODO comment is a reminder to yourself or your team about work that still needs to happen.
Fill in the blank

A comment that marks an open task for later often begins with the word ____.

🤖
This WHY vs WHAT distinction is the whole secret to good comments. 💡

Comments are especially valuable when they explain WHY something is done in the code — not just WHAT is done. The "what" can usually be read straight from the code itself. The "why", on the other hand, only exists in the mind of whoever wrote it.

// We print the message twice so the automated test can detect it reliably
Console.WriteLine("Start");
Console.WriteLine("Start");
This comment explains the intent behind the code — information you couldn't guess from the code alone.
Quick check

What are comments in C# mainly intended for?

Keep your streak going in Swipe Coding

Swipe through every level of C# on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →