Introduction Code Samples
- How do I read console application parameters?
- How do I create properties in C#?
- What are the C# keywords?
- How do I use foreach to iterate array?
- How do I create Hello World program?
- How do I use switch statement?
- How do I use for loop statement?
- How do I add comments in the source code?
- How do I use while loop statement?
- How do I use if-else statement?
- How do I use the continue statement?
- How do I terminate a loop using break statement?
- How do I use do-while statement?
- How do I use if statement?
How do I add comments in the source code?
A well written program usually become a document for itself. Using a good and descriptive fields or method names for example helps the reader of the code to understand the code better.
To intentionally adds comments to our program we can use a single-line comment or a multi-line comments. A single line comment starts with a double forward slash (//) and continues to the end of the line. The multi-line comment starts with /* and ends with */ symbol and it can span in multiple lines.
There is also a documentation comment that contains some XML-formatted data that can be use to create a documentation for classes or methods. This type of documentation can be extracted from the source code to create a documentation file. An example is shown in the sayHello(string name) method in the snippet below.