CodeComment Klass

Definition

Representerar en kommentar.

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
Arv
CodeComment
Attribut

Exempel

Det här exemplet visar hur du använder en CodeComment för att representera en kommentar i källkoden.

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

Kommentarer

CodeComment kan användas för att representera en enskild radkommentar.

A CodeCommentStatement kan innehålla en CodeComment och gör att den kan behandlas som en -instruktion och genereras som kod i en samling instruktioner. Flerradskommentarer kan representeras med flera CodeCommentStatement objekt.

Om du vill inkludera en kommentar i ett CodeDOM-diagram som kan genereras till källkoden lägger du till en CodeComment i , CodeCommentStatementoch lägger till den i instruktionssamlingen för en CodeMemberMethod eller till kommentarssamlingen för ett CodeNamespace eller ett objekt som härleds från CodeTypeMember.

Konstruktorer

Name Description
CodeComment()

Initierar en ny instans av CodeComment klassen.

CodeComment(String, Boolean)

Initierar en ny instans av klassen med hjälp av CodeComment den angivna text- och dokumentationskommentarflaggan.

CodeComment(String)

Initierar en ny instans av CodeComment klassen med den angivna texten som innehåll.

Egenskaper

Name Description
DocComment

Hämtar eller anger ett värde som anger om kommentaren är en dokumentationskommentare.

Text

Hämtar eller anger texten i kommentaren.

UserData

Hämtar användardefinierbara data för det aktuella objektet.

(Ärvd från CodeObject)

Metoder

Name Description
Equals(Object)

Avgör om det angivna objektet är lika med det aktuella objektet.

(Ärvd från Object)
GetHashCode()

Fungerar som standard-hash-funktion.

(Ärvd från Object)
GetType()

Hämtar den aktuella instansen Type .

(Ärvd från Object)
MemberwiseClone()

Skapar en ytlig kopia av den aktuella Object.

(Ärvd från Object)
ToString()

Returnerar en sträng som representerar det aktuella objektet.

(Ärvd från Object)

Gäller för

Se även