CodeCommentStatement 类

定义

表示由单个注释构成的语句。Represents a statement consisting of a single comment.

public ref class CodeCommentStatement : System::CodeDom::CodeStatement
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeCommentStatement : System.CodeDom.CodeStatement
type CodeCommentStatement = class
    inherit CodeStatement
Public Class CodeCommentStatement
Inherits CodeStatement
继承
CodeCommentStatement
属性

示例

此示例演示如何使用CodeCommentStatement来表示源代码中的注释。This example demonstrates using a CodeCommentStatement to represent a comment in source code.

// Create a CodeComment with some example comment text.

// The text of the comment.
// Whether the comment is a comment intended for documentation purposes.
CodeComment^ comment = gcnew CodeComment( "This comment was generated from a System.CodeDom.CodeComment",false );

// Create a CodeCommentStatement that contains the comment, in order
// to add the comment to a CodeTypeDeclaration Members collection.
CodeCommentStatement^ commentStatement = gcnew CodeCommentStatement( comment );

// A C# code generator produces the following source code for the preceeding example code:
// // This comment was generated from a System.CodeDom.CodeComment
// Create a CodeComment with some example comment text.
CodeComment comment = new CodeComment(
    // The text of the comment.
    "This comment was generated from a System.CodeDom.CodeComment",
    // Whether the comment is a comment intended for documentation purposes.
    false );

// Create a CodeCommentStatement that contains the comment, in order
// to add the comment to a CodeTypeDeclaration Members collection.
CodeCommentStatement commentStatement = new CodeCommentStatement( comment );

// A C# code generator produces the following source code for the preceeding example code:

// // This comment was generated from a System.CodeDom.CodeComment
     ' Create a CodeComment with some example comment text.
     Dim comment As New CodeComment( _
        "This comment was generated from a System.CodeDom.CodeComment", _
        False) ' Whether the comment is a documentation comment.
     
     ' Create a CodeCommentStatement that contains the comment, in order
     ' to add the comment to a CodeTypeDeclaration Members collection.
     Dim commentStatement As New CodeCommentStatement(comment)	

     ' A Visual Basic code generator produces the following source code for the preceeding example code:

     ' 'This comment was generated from a System.CodeDom.CodeComment

注解

CodeCommentStatement可用于表示单行注释语句。CodeCommentStatement can be used to represent a single-line comment statement. CodeCommentStatement是一个语句, 因此可将其插入到语句集合, 并将显示在其自己的行上。CodeCommentStatement is a statement, so it can be inserted into a statements collection and will appear on its own line. CodeCommentStatement还可以添加到CodeNamespace或从CodeTypeMember派生的任何对象的注释集合。CodeCommentStatement can also be added to the comments collection of CodeNamespace or any object that derives from CodeTypeMember.

构造函数

CodeCommentStatement()

初始化 CodeCommentStatement 类的新实例。Initializes a new instance of the CodeCommentStatement class.

CodeCommentStatement(CodeComment)

使用指定的注释初始化 CodeCommentStatement 类的新实例。Initializes a new instance of the CodeCommentStatement class using the specified comment.

CodeCommentStatement(String)

使用指定文本作为内容来初始化 CodeCommentStatement 类的新实例。Initializes a new instance of the CodeCommentStatement class using the specified text as contents.

CodeCommentStatement(String, Boolean)

使用指定的文本和文档注释标志初始化 CodeCommentStatement 类的新实例。Initializes a new instance of the CodeCommentStatement class using the specified text and documentation comment flag.

属性

Comment

获取或设置注释的内容。Gets or sets the contents of the comment.

EndDirectives

获取包含结束指令的 CodeDirectiveCollection 对象。Gets a CodeDirectiveCollection object that contains end directives.

(继承自 CodeStatement)
LinePragma

获取或设置代码语句所在的行。Gets or sets the line on which the code statement occurs.

(继承自 CodeStatement)
StartDirectives

获取包含开始指令的 CodeDirectiveCollection 对象。Gets a CodeDirectiveCollection object that contains start directives.

(继承自 CodeStatement)
UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅