Skip to main content

What are C# Comments and how to use them in our code

 
Ziggy Rafiq C# Comments Blog Post


C# Comments


Overview
C# Comments are only for you to read, not for the computer to execute. All the comments displayed in the Code Editor are green by default, which makes it easy to identify those lines, and the C# compiler ignores those parts when it runs your program.

Single-line Comments
You can make any line into the single-line comment by starting it with the two forward slash marks //, indicating the remainder of the line is a comment.

Example


End of line comments
The End of line comments is generally used to describe variables and data types.

Example




Multiline Comments (delimited comments)
Multiline Comments begin with an open comment mark /* and end with a lost comment mark */. All the text between the delimiters is ignored by the compiler.

Example Code


Example Code(Header Comments)


XML Comments
In C# we use XML comment on our methods by simply typing /// to get the XML comment.



Comments