System.Type.GetEvent Method

Returns the System.Reflection.EventInfo object representing the specified public event.

Syntax

public System.Reflection.EventInfo GetEvent (string name)

Parameters

name
The string containing the name of an event that is declared or inherited by the current Type.

Returns

The object representing the specified public event that is declared or inherited by the current Type, if found; otherwise, null.

Exceptions

TypeReason
ArgumentNullException name is null.

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 search for name is case-sensitive. The search includes public static and public instance events.

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 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