C# Comments - c# - c# tutorial - c# net
C# Comment
What are the types of comments in C# ?
- The C# comments are statements that are not executed by the compiler.
- The comments in C# programming can be used to provide explanation of the code, variable, method or class.
- By the help of comments, you can hide the program code also.
- A comment contains information that a programmer wants to add to describe the program.
- Comments are marked with special characters that indicate that they should be ignored by the compiler.
- They have no effect on the final software.
- There are two types of comments in C#.
- Single Line comment
- Multi Line comment
comment in C#
C# Single Line Comment
- The simplest form of comment in C# is the single line comment.
- The line is started with a double forward slash, (//).
- Any text or code following the double slash is ignored during compilation.
- Let's see an example of single line comment in C#.
C# examples - Output :
C# Multi Line Comment
- The C# multi line comment is used to comment multiple lines of code.
- It is surrounded by slash and asterisk (/* ..... */).
- It is useful for commenting out large blocks of code.
- Let's see an example of multi line comment in C#.