Returns all the public members of the current Type.
An array of System.Reflection.MemberInfo objects representing all the public members of the current Type.
-or-
An empty array of type System.Reflection.MemberInfo, if the current Type does not have public members.
Members include properties, methods, fields, events, and so on.
The Type.GetMembers 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 calls the Type.GetMembers(System.Reflection.BindingFlags) method overload, with System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static (System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.Static in Visual Basic). It 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 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 members of the class constraint, or the members of object if there is no class constraint.