There are three styles of comments we can use in C# code.
A single line comments start with // and continues until the end of line.
using System;
class Program
{
static void Main(string[] args)
{
int i = 0;
int j = 2;
//This is a single line comment.
Console.WriteLine("i=" + i);
Console.WriteLine("j=" + j);
}
}
C# multiple line comments start with /* and end with */.
using System;
class Program
{
static void Main(string[] args)
{
int i = 0;
int j = 2;
/*
This is a multi-line comment.
*/
Console.WriteLine("i=" + i);
Console.WriteLine("j=" + j);
}
}
The third type of comments is XML documentation comment.
In the C# source code, the comments may contain XML tags.
Those tags mark the comments to provide information for the code.
using System;
class Program
{
/// <summary>
/// This the XML documentation.
/// </summary>
static void Main(string[] args)
{
int i = 0;
int j = 2;
Console.WriteLine("i=" + i);
Console.WriteLine("j=" + j);
}
}
| w__w_w___.__j___a___v_a__2s_.__c___om_ | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |