C# Fundamentals - Third Edition

Program comments are notes left on programs to explain or highlight the functionality of code. Comments are non-executing code and will not affect the usage of a program. 

Comment Types:

  • Line commentsare for a single line of code and begin with two forward slashes “//”. Anything following the slashes on that line of code will be considered a comment and not execute.
  • Block commentsare for multiple lines of code and begin with one forward slash and an asterisk “/*” and to complete the comment end with an asterisk and a forward slash “*/”.

Example: Line comment

// Anything after two forward slashes on this line will not execute.
Console.Write("Hello World!"); // A comment can also be placed after code.


Example: Block comment

/* Comment out multiple lines of code.
   Anything in this area is also a comment.


Visual Studio has a convenient way to quickly comment or uncomment selected lines of code. Click on the Comment or Uncomment buttons.