An array of System.Reflection.MemberInfo objects representing the public members with the specified name, if found; otherwise, an empty array.
Type Reason ArgumentNullException name is null.
The search for name is case-sensitive. The search includes public static and public instance members.
Members include properties, methods, fields, events, and so on.
The Type.GetMember(string) method does not return members in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which members are returned, because that order varies.
This method overload will not find class initializers (.cctor). To find class initializers, use an overload that takes System.Reflection.BindingFlags, and specify System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic (System.Reflection.BindingFlags.Static Or System.Reflection.BindingFlags.NonPublic in Visual Basic). You can also get the class initializer using the Type.TypeInitializer property.
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. |
If the current Type represents a constructed generic type, this method returns the System.Reflection.MemberInfo 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 members of the class constraint, or the members of object if there is no class constraint.
For generic methods, do not include the type arguments in name. For example, the C# code GetMember("MyMethod<int>") searches for a member with the text name "MyMethod<int>", rather than for a method named MyMethod that has one generic argument of type int.