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; 



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



© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

PrevNext