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
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!");
}
}Comments are executed by the C# compiler like normal code.
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 comment that marks an open task for later often begins with the word ____.
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");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 →