Type::FindMembers Method
Returns a filtered array of MemberInfo objects of the specified member type.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Parameters
- memberType
- Type: System.Reflection::MemberTypes
A MemberTypes object indicating the type of member to search for.
- bindingAttr
- Type: System.Reflection::BindingFlags
A bitmask comprised of one or more BindingFlags that specify how the search is conducted.
-or-
Zero, to return nullptr.
- filter
- Type: System.Reflection::MemberFilter
The delegate that does the comparisons, returning true if the member currently being inspected matches the filterCriteria and false otherwise. You can use the FilterAttribute, FilterName, and FilterNameIgnoreCase delegates supplied by this class. The first uses the fields of FieldAttributes, MethodAttributes, and MethodImplAttributes as search criteria, and the other two delegates use String objects as the search criteria.
- filterCriteria
- Type: System::Object
The search criteria that determines whether a member is returned in the array of MemberInfo objects.
The fields of FieldAttributes, MethodAttributes, and MethodImplAttributes can be used in conjunction with the FilterAttribute delegate supplied by this class.
Return Value
Type: array<System.Reflection::MemberInfo>A filtered array of MemberInfo objects of the specified member type.
-or-
An empty array of type MemberInfo, if the current Type does not have members of type memberType that match the filter criteria.
| Exception | Condition |
|---|---|
| ArgumentNullException | filter is nullptr. |
This method can be overridden by a derived class.
The following BindingFlags filter flags can be used to define which members to include in the search:
You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.
Specify BindingFlags.Instance to include instance members in the search.
Specify BindingFlags.Static to include static members in the search.
Specify BindingFlags.Public to include public members in the search.
Specify BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
The following BindingFlags modifier flags can be used to change how the search works:
BindingFlags.DeclaredOnly to search only the members declared on the Type, not members that were simply inherited.
See System.Reflection::BindingFlags for more information.
Valid values for MemberType are defined in MemberInfo. If no such members are found, an empty array is returned.
To get the class initializer (.cctor) using this method, you must specify BindingFlags::Static | BindingFlags::NonPublic (BindingFlags::Static Or BindingFlags::NonPublic in Visual Basic).
If the current Type represents a type parameter of a generic type or generic method, FindMembers processes any members declared by the class constraint and the interface constraints of the type parameter.
The following example finds all the members in a class that match the specified search criteria, and then displays the matched members.
Note: |
|---|
To run this example, see Building Examples That Use a Demo Method and a TextBlock Control. |
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Note: