CodeComment Class
Represents a comment.
For a list of all members of this type, see CodeComment Members.
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeComment
[Visual Basic] <Serializable> <ClassInterface(ClassInterfaceType.AutoDispatch)> <ComVisible(True)> Public Class CodeComment Inherits CodeObject [C#] [Serializable] [ClassInterface(ClassInterfaceType.AutoDispatch)] [ComVisible(true)] public class CodeComment : CodeObject [C++] [Serializable] [ClassInterface(ClassInterfaceType::AutoDispatch)] [ComVisible(true)] public __gc class CodeComment : public CodeObject [JScript] public Serializable ClassInterface(ClassInterfaceType.AutoDispatch) ComVisible(true) class CodeComment extends CodeObject
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
CodeComment can be used to represent a single line comment.
A CodeCommentStatement can contain a CodeComment and allows it to be treated as a statement and generated as code within a collection of statements. Multi-line comments can be represented with multiple CodeCommentStatement objects.
To include a comment in a CodeDOM graph that can be generated to source code, add a CodeComment to a CodeCommentStatement, and add this to the statements collection of a CodeMemberMethod or to the comments collection of a CodeNamespace or any object that derives from CodeTypeMember.
Example
[Visual Basic, C#, C++] This example demonstrates using a CodeComment to represent a comment in source code.
[Visual Basic] ' 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 [C#] // 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 [C++] // Create a CodeComment with some example comment text. CodeComment* comment = new CodeComment( // The text of the comment. S"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
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.CodeDom
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: System (in System.dll)
See Also
CodeComment Members | System.CodeDom Namespace | CodeCommentStatement | Comments