C# 注释
C# 注释
C# 注释是不由编译器执行的语句。 C# 编程中的注释可用于提供代码、变量、方法或类的解释。借助注释,您还可以隐藏程序代码。
C# 中有两种类型的注释。
单行注释
多行注释
C# 单行注释
单行注释以//(双斜线)开头。我们来看一个 C# 中单行注释的例子。
using System;
public class CommentExample
{
public static void Main(string[] args)
{
int x = 10;//Here, x is a variable
Console.WriteLine(x);
}
}
输出:
C# 多行注释
C# 多行注释用于注释多行代码。它被斜线和星号(/* ..... */) 包围。让我们看一个 C# 中多行注释的例子。
using System;
public class CommentExample
{
public static void Main(string[] args)
{
/* Let's declare and
print variable in C#. */
int x=20;
Console.WriteLine(x);
}
}
输出: