Comment

Comment

A comment is text in your code that the computer ignores when the program runs. It’s meant for humans, not the computer.

What a comment does#

Consider this example:

Console.WriteLine("Hello, World!");

// This is a comment. It's ignored and not executed.

Console.WriteLine("Hello, Again!");
print("Hello, World!")

# This is a comment. It's ignored and not executed.

print("Hello, Again!")
console.log("Hello, World!");

// This is a comment. It's ignored and not executed.

console.log("Hello, Again!");

The output of this program is:

Comment (C#)

This page covers Comment in C#. For a language-agnostic introduction, see Comment.

A comment in C# is text the compiler ignores. C# has two comment syntaxes: single-line and block.

Single-line comment#

A single-line comment starts with // and continues to the end of the line.

// Everything on this line is a comment.
Console.WriteLine("Hello, World!");

You can also write it inline, to the right of code:

Console.WriteLine("Hello, World!"); // Everything to the right is a comment.

Block comment#

A block comment starts with /* and ends with */. Everything between those markers is ignored, regardless of how many lines it spans.

Comment (JavaScript)

This page covers Comment in JavaScript. For a language-agnostic introduction, see Comment.

A comment in JavaScript is text the interpreter ignores. JavaScript has two comment syntaxes: single-line and block.

Single-line comment#

A single-line comment starts with // and continues to the end of the line.

// Everything on this line is a comment.
console.log("Hello, World!");

You can also write it inline, to the right of code:

console.log("Hello, World!"); // Everything to the right is a comment.

Block comment#

A block comment starts with /* and ends with */. Everything between those markers is ignored, regardless of how many lines it spans.

Comment (Python)

This page covers Comment in Python. For a language-agnostic introduction, see Comment.

A comment in Python is text the interpreter ignores. Python has one comment syntax: the single-line comment.

Single-line comment#

A single-line comment starts with # and continues to the end of the line.

# Everything on this line is a comment.
print("Hello, World!")

You can also write it inline, to the right of code:

print("Hello, World!")  # Everything to the right is a comment.

Multi-line comments#

Python has no dedicated block comment syntax. To comment across multiple lines, write a # at the start of each line: