Comments are explanatory statements that you can include in a program to benefit the reader of your code. The compiler ignore everything that appears in the comment, so none of that information affects the result.
A. Single Line comment
A comment beginning with two slashes ( // ) is called a single-line comment. The slashes tell the compiler to ignore everything that follows, until the end of the line.
A comment beginning with two slashes ( // ) is called a single-line comment. The slashes tell the compiler to ignore everything that follows, until the end of the line.
// Prints Hello
Console.WriteLine("Hello");
When you run this code, hello will be displayed to the screen. The // prints hello line is a comment and will not appear as output.
B. Multi-Line Comments
Comments that require multiple lines begin with /* and end with */ at the end of the comment block. You can place them on the same line or insert one or more lines between them.
/*
Some long
comment text
*/
int x = 43;
Console.WriteLine(x);
adding comments to your code is good programming practice. It facelitates a clear understanding of the code for you and for others who read it.
Next : C# series 1.1d : Operator
B. Multi-Line Comments
Comments that require multiple lines begin with /* and end with */ at the end of the comment block. You can place them on the same line or insert one or more lines between them.
/*
Some long
comment text
*/
int x = 43;
Console.WriteLine(x);
adding comments to your code is good programming practice. It facelitates a clear understanding of the code for you and for others who read it.
Next : C# series 1.1d : Operator
No comments:
Post a Comment