Comments

These are explainatory notes included in your code following a single quotation mark. These are used to describe important statements.
Comments are displayed in green.
You should insert comments to make your code more readable
You can put comments anywhere in your program


In C# comments start with two forward slashes //
We can use an entire line or append to the end of a line.

//This is a really useful function 
int Result = 50 * Number; //calculate result

A comment can also be indicated using the demited sequence /* and */
Everything that follows the sequence /* is considered to be a comment, this can extend over multiple lines

/* This is a 
multi line comment */

You can also add very short inline comments

int Result /* 50 */ 25 * Number; 

Place the comment on a separate line, not at the end of a line of code.
Begin comment text with an uppercase letter.
End comment text with a period.
Insert one space between the comment delimiter (//) and the comment text, as shown in the following example.
Don't create formatted blocks of asterisks around comments.
Ensure all public members have the necessary XML comments providing appropriate descriptions about their behavior.


Three Forward Slashes ///

Another option is to use three forward slashes
This will comment until the end of the line

/// returns a boolean indicating if the file is read-only 
private bool IsReadOnly(string sFullPath)

If you use three forward slashes instead of two, the comments can also be used to automatically generate documentation for your source code as a separate xml file.
This means that commenting every method allows you to have complete documentation automatically generated and updated when you modify your code.



VB

In VB you use an apostrophe to denote the start of a commen and the comment lasts until the end of the line



© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext