C# Foundations · Lesson 14

Comments

A comment is for a person. The compiler skips it.

How it works

The line that starts with // is not executed, so it cannot change total. The comment on the first line is also skipped, and WriteLine still prints 10. Comments do not replace a Check diagnostic.

A working example

var total = 10m; // kept
// This line is not code.
Console.WriteLine(total);

Expected output

10
Try this
The compiler ignores comments.