CodeComment Klasa

Definicja

Reprezentuje komentarz.

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
Dziedziczenie
CodeComment
Atrybuty

Przykłady

W tym przykładzie pokazano użycie elementu do CodeComment reprezentowania komentarza w kodzie źródłowym.

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

Uwagi

CodeComment Może służyć do reprezentowania pojedynczego komentarza wiersza.

Obiekt CodeCommentStatement może zawierać CodeComment element i umożliwia traktowanie go jako instrukcji i generowanego jako kod w kolekcji instrukcji. Komentarze wielowierszowe mogą być reprezentowane za pomocą wielu CodeCommentStatement obiektów.

Aby uwzględnić komentarz w grafie CodeDOM, który można wygenerować w kodzie źródłowymCodeCommentStatement, dodaj CodeComment element do elementu i dodaj go do kolekcji instrukcji lub do kolekcji CodeMemberMethod komentarzy obiektu lub dowolnego obiektu pochodzącego CodeNamespace z CodeTypeMemberklasy .

Konstruktory

Nazwa Opis
CodeComment()

Inicjuje nowe wystąpienie klasy CodeComment.

CodeComment(String, Boolean)

Inicjuje nowe wystąpienie CodeComment klasy przy użyciu określonego tekstu i flagi komentarza dokumentacji.

CodeComment(String)

Inicjuje nowe wystąpienie CodeComment klasy z określonym tekstem jako zawartością.

Właściwości

Nazwa Opis
DocComment

Pobiera lub ustawia wartość wskazującą, czy komentarz jest komentarzem dokumentacji.

Text

Pobiera lub ustawia tekst komentarza.

UserData

Pobiera dane zdefiniowane przez użytkownika dla bieżącego obiektu.

(Odziedziczone po CodeObject)

Metody

Nazwa Opis
Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też