C# Comments

Comments in C# can be used to explain code and make it easier to read. They can also be used to prevent the execution of part of a code when testing alternatives.

Single-line comments

Single-line comments start with two forward slashes (//). Any text between // and the end of the line will be ignored by C# (will not be executed).

This is an example for a single-line comment:

Multi-line comments

Multi-line comments start with /* and end with */. Any text between /* and */ will be ignored by C#.

This is an example for a multi-line comment:

Exercise

In the program you wrote in the previous lesson, add one single-line comment which says that this program was created by [your name] and one multi-line comment which explains what the code does.