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.
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, Boolean)

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

CodeComment(String)

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

Свойства

Имя Описание
DocComment

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

Text

Возвращает или задает текст комментария.

UserData

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

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

Методы

Имя Описание
Equals(Object)

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

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

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

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

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

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

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

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

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

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

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

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