Getting Started with C Fundamentals Notes
- 2021-12-11 08:40:07
- OfStack
Comments are 1 "descriptive text" in the code. Comments themselves do not participate in compiling and running programs, but are only for programmers to read.
Annotations are divided into single-line annotations, multi-line annotations and document annotations.
The symbol of a single-line comment is two slashes "//", and the content to the right of the two slashes is the comment, while the code to the left will not be affected.
A multi-line comment begins with "/*" and ends with "*/", and the content in between is a comment, which can contain multiple lines.
A document comment is written in front of a class, method, or property, and its symbol is three slash "///".
namespace Test
{
/// <summary>
/// This class implements "greeting" (document comment)
/// <summary>
class Program
{
static void Main(string[] args)
{
/*
* The following is the declaration of the variable
* No. 1 2 Row is output
* (Multi-line comment)
*/
string name = " Mary ";// Name (single line comment)
Console.WriteLine(" My name is "+name);
}
}
}
Note: Console. WriteLine () in the code differs from the previous Console. Write (), which does not wrap, whereas the former wraps after printing.