CodeComment 类

定义

表示注释。Represents a comment.

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

示例

此示例演示如何使用CodeComment来表示源代码中的注释。This example demonstrates using a CodeComment 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

注解

CodeComment可用于表示单行注释。CodeComment can be used to represent a single line comment.

CodeCommentStatement 可以CodeComment包含并允许将其视为语句并在语句的集合中生成为代码。A CodeCommentStatement can contain a CodeComment and allows it to be treated as a statement and generated as code within a collection of statements. 多行注释可以用多个CodeCommentStatement对象表示。Multi-line comments can be represented with multiple CodeCommentStatement objects.

若要在 CodeDOM 图中包含可生成到源代码的注释CodeComment , 请将添加CodeCommentStatement到, 并将其添加到CodeMemberMethod或派生自CodeNamespace 的或任何对象的注释集合CodeTypeMemberTo include a comment in a CodeDOM graph that can be generated to source code, add a CodeComment to a CodeCommentStatement, and add this to the statements collection of a CodeMemberMethod or to the comments collection of a CodeNamespace or any object that derives from CodeTypeMember.

构造函数

CodeComment()

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

CodeComment(String)

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

CodeComment(String, Boolean)

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

属性

DocComment

获取或设置一个值,该值指示注释是否是文档注释。Gets or sets a value that indicates whether the comment is a documentation comment.

Text

获取或设置注释文本。Gets or sets the text of the comment.

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)

适用于

另请参阅