CodeComment Classe

Définition

Représente un commentaire.

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
Héritage
CodeComment
Attributs

Exemples

Cet exemple illustre l’utilisation d’un CodeComment commentaire dans le code source.

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

Remarques

CodeComment peut être utilisé pour représenter un commentaire de ligne unique.

Un CodeCommentStatement peut contenir un CodeComment et lui permet d’être traité comme une instruction et généré comme du code dans une collection d’instructions. Les commentaires multilignes peuvent être représentés avec plusieurs CodeCommentStatement objets.

Pour inclure un commentaire dans un graphique CodeDOM qui peut être généré au code source, ajoutez un à un CodeCommentStatementet ajoutez-le à la collection d’instructions d’une CodeMemberMethod collection ou à la collection de commentaires d’un CodeNamespace ou d’un objet dérivé de CodeTypeMember.CodeComment

Constructeurs

CodeComment()

Initialise une nouvelle instance de la classe CodeComment.

CodeComment(String)

Initialise une nouvelle instance de la classe CodeComment avec le texte spécifié comme contenu.

CodeComment(String, Boolean)

Initialise une nouvelle instance de la classe CodeComment avec le texte et l'indicateur de commentaire de documentation spécifiés.

Propriétés

DocComment

Obtient ou définit une valeur qui indique si le commentaire est un commentaire de la documentation.

Text

Obtient ou définit le texte du commentaire.

UserData

Obtient les données définissables par l'utilisateur pour l'objet en cours.

(Hérité de CodeObject)

Méthodes

Equals(Object)

Détermine si l'objet spécifié est égal à l'objet actuel.

(Hérité de Object)
GetHashCode()

Fait office de fonction de hachage par défaut.

(Hérité de Object)
GetType()

Obtient le Type de l'instance actuelle.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Object actuel.

(Hérité de Object)
ToString()

Retourne une chaîne qui représente l'objet actuel.

(Hérité de Object)

S’applique à

Voir aussi