CodeComment Classe

Definizione

Rappresenta un commento.

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
Ereditarietà
CodeComment
Attributi

Esempio

In questo esempio viene illustrato l'uso di un oggetto CodeComment per rappresentare un commento nel codice sorgente.

// 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

Commenti

CodeComment può essere usato per rappresentare un singolo commento di riga.

Un CodeCommentStatement può contenere un CodeComment oggetto e consente di essere considerato come un'istruzione e generato come codice all'interno di una raccolta di istruzioni. I commenti a più righe possono essere rappresentati con più CodeCommentStatement oggetti.

Per includere un commento in un grafico CodeDOM che può essere generato nel codice sorgente, aggiungere a un CodeComment oggetto e aggiungerlo all'insieme di istruzioni di un CodeCommentStatemento all'insieme commenti di un CodeMemberMethodCodeNamespace oggetto o di qualsiasi oggetto che deriva da CodeTypeMember.

Costruttori

CodeComment()

Inizializza una nuova istanza della classe CodeComment.

CodeComment(String)

Consente l'inizializzazione di una nuova istanza della classe CodeComment utilizzando il testo specificato come contenuto.

CodeComment(String, Boolean)

Consente l'inizializzazione di una nuova istanza della classe CodeComment con il testo e il flag di documentazione tratta dal commento specificati.

Proprietà

DocComment

Ottiene o imposta un valore che indica se il commento è relativo alla documentazione.

Text

Ottiene o imposta il testo del commento.

UserData

Ottiene i dati definibili dall'utente per l'oggetto corrente.

(Ereditato da CodeObject)

Metodi

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Si applica a

Vedi anche