CodeComment Třída

Definice

Představuje komentář.

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
Dědičnost
CodeComment
Atributy

Příklady

Tento příklad ukazuje použití k CodeComment reprezentaci komentáře ve zdrojovém kódu.

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

Poznámky

CodeComment lze použít k vyjádření jednořádkového komentáře.

A CodeCommentStatement může obsahovat CodeComment a umožňuje, aby se s ním zacházelo jako s příkazem a vygenerovalo ho jako kód v rámci kolekce příkazů. Víceřádkové komentáře mohou být reprezentovány více CodeCommentStatement objekty.

Chcete-li do grafu CodeDOM zahrnout komentář, který lze vygenerovat do zdrojového kódu, přidejte CodeComment do objektu CodeCommentStatementa přidejte ho CodeMemberMethod do kolekce příkazů nebo do kolekce komentářů objektu CodeNamespace nebo libovolného objektu, který je odvozen z CodeTypeMember.

Konstruktory

CodeComment()

Inicializuje novou instanci CodeComment třídy .

CodeComment(String)

Inicializuje novou instanci CodeComment třídy se zadaným textem jako obsahem.

CodeComment(String, Boolean)

Inicializuje novou instanci CodeComment třídy pomocí zadaného textu a příznaku komentáře k dokumentaci.

Vlastnosti

DocComment

Získá nebo nastaví hodnotu, která označuje, zda komentář je dokumentační komentář.

Text

Získá nebo nastaví text komentáře.

UserData

Získá uživatelsky definovatelná data pro aktuální objekt.

(Zděděno od CodeObject)

Metody

Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
GetHashCode()

Slouží jako výchozí hashovací funkce.

(Zděděno od Object)
GetType()

Type Získá z aktuální instance.

(Zděděno od Object)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Objectsouboru .

(Zděděno od Object)
ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro

Viz také