CodeComment CodeComment CodeComment CodeComment Class

定義

表示註解。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
繼承
CodeCommentCodeCommentCodeCommentCodeComment
屬性

範例

這個範例示範如何使用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() CodeComment() CodeComment()

初始化 CodeComment 類別的新執行個體。Initializes a new instance of the CodeComment class.

CodeComment(String) CodeComment(String) CodeComment(String) CodeComment(String)

使用指定的文字為內容,初始化 CodeComment 類別的新執行個體。Initializes a new instance of the CodeComment class with the specified text as contents.

CodeComment(String, Boolean) CodeComment(String, Boolean) CodeComment(String, Boolean) CodeComment(String, Boolean)

使用指定的文字和文件註解旗標來初始化 CodeComment 類別的新執行個體。Initializes a new instance of the CodeComment class using the specified text and documentation comment flag.

屬性

DocComment DocComment DocComment DocComment

取得或設定數值,表示註解是否為文件註解。Gets or sets a value that indicates whether the comment is a documentation comment.

Text Text Text Text

取得或設定註解的內容。Gets or sets the text of the comment.

UserData UserData UserData UserData

取得目前物件的使用者可定義資料。Gets the user-definable data for the current object.

(Inherited from CodeObject)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於

另請參閱