System.Type.GetEvents Method

Returns all the public events that are declared or inherited by the current Type.

Syntax

public virtual System.Reflection.EventInfo[] GetEvents ()

Returns

An array of System.Reflection.EventInfo objects representing all the public events which are declared or inherited by the current Type.

-or-

An empty array of type System.Reflection.EventInfo, if the current Type does not have public events.

Remarks

An event is considered public to reflection if it has at least one method or accessor that is public. Otherwise the event is considered private, and you must use System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static (in Visual Basic, combine the values using Or) to get it.

The Type.GetEvents method does not return events in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which events are returned, because that order varies.

This method can be overridden by a derived class.

The following table shows what members of a base class are returned by the Get methods when reflecting on a type.

Constructor

No

No

Field

No

Yes. A field is always hide-by-name-and-signature.

Event

Not applicable

The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.

Method

No

Yes. A method (both virtual and non-virtual) can be hide-by-name or hide-by-name-and-signature.

Nested Type

No

No

Property

Not applicable

The common type system rule is that the inheritance is the same as that of the methods that implement the property. Reflection treats properties as hide-by-name-and-signature. See note 2 below.

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

If the current Type represents a constructed generic type, this method returns the System.Reflection.EventInfo objects with the type parameters replaced by the appropriate type arguments.

If the current Type represents a type parameter in the definition of a generic type or generic method, this method searches the events of the class constraint.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0