Quick Links
C#-Comments are explanatory statements that you can include in a program to benefit the reader of your code.
The compiler ignores everything that appears in the comment, so none of that information affects the result.
There are two types of comments in C#.
- Single Line comment
- Multi Line comment
Single Line C#-Comments :
A comment beginning with two slashes (//) is called a single-line comment.
Example :
using System;
public class CommentExample
{
public static void Main(string[] args)
{
int x = 10;//Here, x is a variable
Console.WriteLine(x);
}
}
Multi Line Comment :
Comments that require multiple lines begin with /* and end with */ at the end of the comment block.
Example :
using System;
public class CommentExample
{
public static void Main(string[] args)
{
/* Let's declare and
print variable in C#. */
int x=20;
Console.WriteLine(x);
}
}
Recommended Posts: