C# Comments

C# Comments

 

As you have already seen, comments in C# start with a double forward slash and continue to the end of the current line. C# also recognizes Cstyle comments which begin with /* and continue through any number of lines until the */ symbols are found.

//C# single-line comment

/*other C# comment style*/

/* also can go on

for any number of lines*/

You can’t nest C# comments; once a comment begins in one style it continues until that style concludes.

Your initial reaction as you are learning a new language may be to ignore comments, but they are just as important at the outset as they are later. A program never gets commented at all unless you do it as you write it, and if you ever want to use that code again, you’ll find it very helpful to have some comments to help you in deciphering what you meant for it to do.

For this reason, many programming instructors refuse to accept programs that are not thoroughly commented.

 

Shashi Ray

Ebook Download
View all
Learn
View all