Introduction to C# basics - a simple understanding of comments

黄舟
Release: 2017-03-17 11:55:57
Original
1885 people have browsed it

This article mainly introduces the relevant knowledge of comments in C#, which has a very good reference value. Let’s take a look at it with the editor.

comments are in the code some "explanatory text". The comments themselves will not participate in the compilation and running of the program, they are only read by the programmer.

Comments are divided into: single-line comments, multi-line comments, and document comments.

The symbol for a single-line comment is two slashes "//". The content on the right side of the two slashes is the comment, and the code on the left side will not be affected.

Multi-line comments start with "/*" and end with "*/". The content in between is the comment and can contain multiple lines.

Documentation comments are written in front of classes, methods or properties, and their symbols are three slashes "///".

 namespace Test
{
 /// <summary>
 /// 本类实现“打招呼”(文档注释)
 /// <summary>
 class Program
 {
 static void Main(string[] args)
 {
 /*
 *下面是变量的声明
 *第二行是输出
 *(多行注释)
 */
 string name = "玛丽";//姓名(单行注释)
 Console.WriteLine("我叫"+name);
 }
 }
}
Copy after login

Note: The Console.WriteLine() in the code is different from the previous Console.Write(). The latter does not wrap lines, while the former does after printing. Line break.

The above is the detailed content of Introduction to C# basics - a simple understanding of comments. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!