CodeComment Класс

Определение

Представляет комментарий.

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
Наследование
CodeComment
Атрибуты

Примеры

В этом примере демонстрируется использование для 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(
    // 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

Комментарии

CodeCommentможет использоваться для представления одного строковый комментарий.

Может CodeCommentStatement содержать CodeComment и позволяет обрабатывать его как оператор и создавать как код в коллекции операторов. Многострочный комментарий можно представить несколькими CodeCommentStatement объектами.

Чтобы включить комментарий в граф CodeDOM, который можно создать в исходном коде, добавьте CodeComment в CodeCommentStatement, а затем добавьте его в коллекцию инструкций CodeMemberMethod или в коллекцию комментариев объекта или любого объекта, наследуемого CodeNamespace от CodeTypeMember.

Конструкторы

CodeComment()

Инициализирует новый экземпляр класса CodeComment.

CodeComment(String)

Инициализирует новый экземпляр класса CodeComment с указанным текстом в качестве содержимого.

CodeComment(String, Boolean)

Инициализирует новый экземпляр класса CodeComment, используя указанный текст и флаг комментария документации.

Свойства

DocComment

Получает или задает значение, указывающее, является ли комментарий комментарием документации.

Text

Получает или задает текст комментария.

UserData

Получает определяемые пользователем данные для текущего объекта.

(Унаследовано от CodeObject)

Методы

Equals(Object)

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
GetHashCode()

Служит хэш-функцией по умолчанию.

(Унаследовано от Object)
GetType()

Возвращает объект Type для текущего экземпляра.

(Унаследовано от Object)
MemberwiseClone()

Создает неполную копию текущего объекта Object.

(Унаследовано от Object)
ToString()

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)

Применяется к

См. также раздел