CodeComment 类

定义

表示注释。

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

示例

此示例演示如何使用 A 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 可用于表示单行注释。

A CodeCommentStatement 可以包含并允许 CodeComment 将其视为语句,并在语句集合中生成为代码。 可以使用多个 CodeCommentStatement 对象表示多行注释。

若要在 CodeDOM 图形中包含可生成到源代码的注释,请向 a CodeComment添加一个CodeCommentStatement注释,并将其添加到一个或多个CodeMemberMethodCodeNamespace派生自CodeTypeMember的对象的注释集合。

构造函数

名称 说明
CodeComment()

初始化 CodeComment 类的新实例。

CodeComment(String, Boolean)

使用指定的文本和文档注释标志初始化类的新实例 CodeComment

CodeComment(String)

使用指定文本作为内容初始化类的新实例 CodeComment

属性

名称 说明
DocComment

获取或设置一个值,该值指示注释是否为文档注释。

Text

获取或设置注释的文本。

UserData

获取当前对象的用户可定义数据。

(继承自 CodeObject)

方法

名称 说明
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅