SoFunction
Updated on 2025-04-10

Introduction to C# Basics--Notes

Comments are some "explanatory text" in the code. The comment itself will not participate in the compilation and operation of the program and is only for programmers to read.

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

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

Multi-line comments start with "/*" and end with "*/". The content between them is comments, which can contain multiple lines.

Document comments are written before a class, method or property, and its symbol is 3 slashes "///".

 namespace Test
{
 /// <summary>
 /// This class implements "say hello" (document comments) /// <summary>
 class Program
 {
 static void Main(string[] args)
 {
 /*
  *The following is the declaration of the variable
  *The second line is the output
  * (multiple line comment)
  */
 string name = "Mary";//Name (single-line comment) ("My name is"+name);
 }
 }
}

Notice:The () in the code is different from the previous () where the latter does not wrap the line, while the former will wrap the line after printing.

The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!