C# TutorialLesson 6Free preview
C# Comments
This lesson is part of C# · All levels
Summary
Comment is a note that the compiler ignores and uses to explain the code. C# provides one-line commentary, block commentary for many lines, as well as XML-format documentation commentary. Comments should explain the reasons behind the code, rather than repeating what is already clear from the code.
Key points
- A double slash comments on one line, while a block that is preceded by an asterisk double slash bends many lines.
- The documentation commentary with three slashes produces XML documentation that the IDE can read.
- The compiler never executes a comment so the comment does not affect the program's outcome.
- Any comments that are no longer relevant should be deleted to keep the code clean.
- To temporarily disable some code, block comments is more practical than adding double slashes to each line.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.