A way of annotating your code, perhaps so that you know what that code is for, or to tell others that there may be an issue with that piece of code that you have not yet overcome.

While comments are visible to you, the computer will ignore – skip over – them when running the code.

You can use comments where you want to write something down, without worrying that the computer will try to do something with it.

There are three different types of comment:

  • In-line – In-line means that you use the signifier for a comment on each line that you are writing.
  • Multi-line – Multiline comments usually have a signifier to start the comment, and one to end it.
  • Documentation – The documentation type will generate an XML file for you when you compile your program.

There are a few ways of writing a comment, depending on the programming language you are using:

In-line comments Multi-line comments Documentation comments
// this is a comment
/* This is
a comment
several lines /*
/// <summary>
/// A summary of this code
/// <remarks>
/// A longer comment describing how the code functions
// This is
// a comment
// spanning
// several lines
<!-- This is a comment -->