Freigeben über


CodeComment-Klasse

Stellt einen Kommentar dar.

Namespace: System.CodeDom
Assembly: System (in system.dll)

Syntax

'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeComment
    Inherits CodeObject
'Usage
Dim instance As CodeComment
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeComment : CodeObject
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeComment : public CodeObject
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeComment extends CodeObject
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeComment extends CodeObject

Hinweise

Mit CodeComment kann ein einzeiliger Kommentar dargestellt werden.

Ein CodeCommentStatement kann einen CodeComment enthalten, der als Anweisung behandelt und als Code in einer Auflistung von Anweisungen generiert werden kann. Mehrzeilige Kommentare können mithilfe von mehreren CodeCommentStatement-Objekten dargestellt werden.

Um einen Kommentar für die Generierung als Quellcode in ein CodeDOM-Diagramm einzubinden, fügen Sie einem CodeCommentStatement einen CodeComment hinzu. Fügen Sie dies anschließend einer Anweisungsauflistung einer CodeMemberMethod oder der Kommentarauflistung eines CodeNamespace oder eines beliebigen von CodeTypeMember abgeleiteten Objekts hinzu.

Beispiel

In diesem Beispiel wird veranschaulicht, wie mit einem CodeComment ein Kommentar in Quellcode dargestellt wird.

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

// 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("This comment was generated "
    + "from a System.CodeDom.CodeComment", false);
// The text of the comment.
// Whether the comment is a comment intended for documentation purposes.
// Create a CodeCommentStatement that contains the comment, in order
// to add the comment to a CodeTypeDeclaration Members collection.
CodeCommentStatement commentStatement = new 
    CodeCommentStatement(comment);
// A VJ# code generator produces the following source code for the 
// preceeding example code:
// This comment was generated from a System.CodeDom.CodeComment

Vererbungshierarchie

System.Object
   System.CodeDom.CodeObject
    System.CodeDom.CodeComment

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

CodeComment-Member
System.CodeDom-Namespace
CodeCommentStatement
Comments