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
屬性

範例

此範例示範如何使用 CodeComment 來表示原始程式碼中的批注。

// 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 可以用來表示單行批注。

CodeCommentStatement可以包含 CodeComment ,並允許將其視為 語句,並在語句集合內產生為程序代碼。 多行批注可以使用多個 CodeCommentStatement 物件來表示。

若要在可產生至原始程式碼的 CodeDOM 圖形中包含批注,請將 加入CodeCommentCodeCommentStatement至 ,並將這個 加入至 的 CodeMemberMethod 語句集合或 的批注集合,或任何衍生自 CodeTypeMember的物件CodeNamespace

建構函式

CodeComment()

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

CodeComment(String)

使用指定的文字為內容,初始化 CodeComment 類別的新執行個體。

CodeComment(String, Boolean)

使用指定的文字和文件註解旗標來初始化 CodeComment 類別的新執行個體。

屬性

DocComment

取得或設定數值,表示註解是否為文件註解。

Text

取得或設定註解的內容。

UserData

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

(繼承來源 CodeObject)

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱