CodeMemberEvent 类

定义

表示一个类型的事件的声明。Represents a declaration for an event of a type.

public ref class CodeMemberEvent : System::CodeDom::CodeTypeMember
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeMemberEvent : System.CodeDom.CodeTypeMember
type CodeMemberEvent = class
    inherit CodeTypeMember
Public Class CodeMemberEvent
Inherits CodeTypeMember
继承
CodeMemberEvent
属性

示例

此示例演示CodeMemberEvent如何使用来声明System.EventHandler采用委托的事件:This example demonstrates use of a CodeMemberEvent to declare an event that takes a System.EventHandler delegate:

// Declares an event that accepts a delegate type of System.EventHandler.
CodeMemberEvent^ event1 = gcnew CodeMemberEvent;

// Sets a name for the event.
event1->Name = "TestEvent";

// Sets the type of event.
event1->Type = gcnew CodeTypeReference( "System.EventHandler" );

// A C# code generator produces the following source code for the preceeding example code:
//    private event System.EventHandler TestEvent;
// Declares an event that accepts a delegate type of System.EventHandler.
CodeMemberEvent event1 = new CodeMemberEvent();
// Sets a name for the event.
event1.Name = "TestEvent";
// Sets the type of event.
event1.Type = new CodeTypeReference("System.EventHandler");

// A C# code generator produces the following source code for the preceeding example code:

//    private event System.EventHandler TestEvent;
' Declares an event that accepts a delegate type of System.EventHandler.
Dim event1 As New CodeMemberEvent()
' Sets a name for the event.
event1.Name = "TestEvent"
' Sets the type of event.
event1.Type = New CodeTypeReference("System.EventHandler")

' A Visual Basic code generator produces the following source code for the preceeding example code:

'     Private Event TestEvent As System.EventHandler

注解

CodeMemberEvent可用于表示类型的事件成员。CodeMemberEvent can be used to represent event members of a type. CodeMemberEvent具有一些属性, 用于指示事件的数据类型、是否私下实现数据类型以及成员事件实现的接口类型 (如果有)。CodeMemberEvent has properties to indicate the data type of the event, whether it privately implements a data type, and what interface types, if any, the member event implements.

构造函数

CodeMemberEvent()

初始化 CodeMemberEvent 类的新实例。Initializes a new instance of the CodeMemberEvent class.

属性

Attributes

获取或设置成员的特性。Gets or sets the attributes of the member.

(继承自 CodeTypeMember)
Comments

获取类型成员的注释集合。Gets the collection of comments for the type member.

(继承自 CodeTypeMember)
CustomAttributes

获取或设置成员的自定义特性。Gets or sets the custom attributes of the member.

(继承自 CodeTypeMember)
EndDirectives

获取成员的结束指令。Gets the end directives for the member.

(继承自 CodeTypeMember)
ImplementationTypes

获取或设置该成员事件实现的数据类型。Gets or sets the data type that the member event implements.

LinePragma

获取或设置类型成员语句所在的行。Gets or sets the line on which the type member statement occurs.

(继承自 CodeTypeMember)
Name

获取或设置成员名。Gets or sets the name of the member.

(继承自 CodeTypeMember)
PrivateImplementationType

获取或设置私下实现的数据类型(如果有的话)。Gets or sets the privately implemented data type, if any.

StartDirectives

获取成员的开始指令。Gets the start directives for the member.

(继承自 CodeTypeMember)
Type

获取或设置处理事件的委托类型的数据类型。Gets or sets the data type of the delegate type that handles the event.

UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于