Searches for the members defined for the current Type whose System.Reflection.DefaultMemberAttribute is set.
An array of System.Reflection.MemberInfo objects representing all default members of the current Type.
-or-
An empty array of type System.Reflection.MemberInfo, if the current Type does not have default members.
The Type.GetDefaultMembers 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 can be overridden by a derived class.
Members include properties, methods, fields, events, and so on.
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. For example, if class C<T> has a property P that returns T, calling Type.GetDefaultMembers on C<int> returns int P in C# (Property P As Integer in Visual Basic).
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.