Type.FindMembers() Method in C# with Examples Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Type.FindMembers(MemberTypes, BindingFlags, MemberFilter, Object) Method is used to return a filtered array of MemberInfo objects of the specified member type.Syntax: public virtual System.Reflection.MemberInfo[] FindMembers (System.Reflection.MemberTypes memberType, System.Reflection.BindingFlags bindingAttr, System.Reflection.MemberFilter filter, object filterCriteria); Parameters: memberType: It indicates that what type of member should be searched.bindingAttr: It used to specify how the search is conducted or Zero, to return null.filter: It does the comparisons, returning true if the member currently being inspected matches the filterCriteria and false otherwise.filterCriteria: The search criteria that determines whether a member is returned in the array of MemberInfo objects. 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, internal, and protected members) in the search. Return Value: This method returns A filtered array of MemberInfo objects of the specified member type. or An empty array of type MemberInfo,Exception: This method throws ArgumentNullException if filter is null.Example: csharp // C# program to demonstrate the // Type.FindMembers(MemberTypes, // BindingFlags, MemberFilter, // Object) Method using System; using System.Globalization; using System.Reflection; class GFG { // Main Method public static void Main() { // Declaring and initializing object of Type Type objType = typeof(string); // Creating try-catch block for handling Exception try { // Declaring and initializing the object of MemberTypes // that indicates the type of member to search for. MemberTypes mt = MemberTypes.All; // Declaring and initializing the object of BindingFlags // that specify how the search is conducted. BindingFlags ba = BindingFlags.Public | BindingFlags.Instance; // Declaring and initializing MemberFilter // which help the delegate that compares // the MemberInfo against filterCriteria. MemberFilter mf = new MemberFilter(Search); // Declaring and initializing object of filterCriteria // the search criteria that determines whether a member is // returned in the array of MemberInfo objects or not object filterCriteria = "Equals"; // Getting filtered array of MemberInfo by // using FindMembers() Method MemberInfo[] info = objType.FindMembers(mt, ba, mf, filterCriteria); // Display the Result for (int index = 0; index < info.Length; index++) Console.WriteLine("Result of FindMembers - {0}", info[index].ToString()); } // catch ArgumentNullException here catch (ArgumentNullException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } // Defining MyInterfaceFilter // which helps to fix the certain condition // on which filtration took place public static bool Search(MemberInfo info, Object obj) { // Compare the name of the member // function with the filter criteria. if (info.Name.ToString() == obj.ToString()) return true; else return false; } } Output: Result of FindMembers - Boolean Equals(System.Object) Result of FindMembers - Boolean Equals(System.String) Result of FindMembers - Boolean Equals(System.String, System.StringComparison) Reference: https://learn.microsoft.com/en-us/dotnet/api/system.type.findmembers?view=netcore-3.0 Comment More infoAdvertise with us Next Article Type.FindInterfaces() Method in C# with Examples R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp-Type-Class Similar Reads Type.FindInterfaces() Method in C# with Examples Type.FindInterfaces(TypeFilter, Object) Method is used to return an array of Type objects which represents a filtered list of interfaces implemented or inherited by the current Type. All of the interfaces implemented by this class are considered during the search, whether declared by a base class or 3 min read Object.MemberwiseClone Method in C# with Examples Object.MemberwiseClone Method is used to create a shallow copy or make clone of the current Object. Shallow copy is a bit-wise copy of an object. In this case, a new object is created and that object has an exact copy of the existing object. Basically, this method copies the non-static fields of the 3 min read List.FindIndex() Method in C# with Examples List<T>.FindIndex Method is used to search for an element that matches the conditions defined by a specified predicate and returns the index of the first occurrence within the List<T>. If an item that matches the conditions is not found then this method will return -1. There are 3 method 6 min read Single.GetTypeCode Method in C# with Examples Single.GetTypeCode method is used to get the TypeCode for value type Single. Syntax: public TypeCode GetTypeCode (); Return Value: This method returns the enumerated constant Single. Below programs illustrate the use of the above discussed-method: Example 1: csharp // C# program to illustrate the // 1 min read C# | Type.GetMembers() Method Type.GetMembers() Method is used to get the members (properties, methods, fields, events, and so on) of the current Type. There are 2 methods in the overload list of this method as follows: GetMembers() Method GetMembers(BindingFlags) Method GetMembers() Method This method is used to return all the 4 min read C# | Type.GetDefaultMembers() Method Type.GetDefaultMembers() Method is used to find the members defined for the current Type whose DefaultMemberAttribute is set. Syntax: public virtual System.Reflection.MemberInfo[] GetDefaultMembers (); Return Value: This method returns an array of MemberInfo objects representing all default members 2 min read Like