CodeComment 類別

定義

代表註解。

public ref 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
[<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 可以包含 a CodeComment ,並允許將其視為陳述句,並在陳述式集合中生成為程式碼。 多行註解可以用多個 CodeCommentStatement 物件來表示。

若要在可生成原始碼的 CodeDOM 圖中包含註解,請將 a CodeComment 加入 CodeCommentStatement,並將其加入 a CodeMemberMethod 的語句集合,或 的註解集合 CodeNamespace ,或任何源自 CodeTypeMember的物件。

建構函式

名稱 Description
CodeComment()

初始化 CodeComment 類別的新執行個體。

CodeComment(String, Boolean)

使用指定的文字與文件註解標誌初始化該類別的新實例 CodeComment

CodeComment(String)

初始化一個新的類別實例 CodeComment ,內容為指定的文字。

屬性

名稱 Description
DocComment

取得或設定一個值,指示該註解是否為文件註解。

Text

取得或設定留言的文字。

UserData

取得目前物件的使用者可定義資料。

(繼承來源 CodeObject)

方法

名稱 Description
Equals(Object)

判斷指定的 物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

適用於

另請參閱