Returns a System.Reflection.MethodInfo object that reflects the method that has the specified name and is defined in the type represented by the current instance.
- name
- A string containing the name of the method to be returned.
- bindingAttr
- A bitwise combination of System.Reflection.BindingFlags values that control the binding process. If zero is specified, this method returns null .
A System.Reflection.MethodInfo object that reflects the method that is defined in the type represented by the current instance and matches the specified criteria, if found; otherwise, null.
Type Reason System.Security.Permissions.ReflectionPermission Requires permission to retrieve information on non-public members of types in loaded assemblies. See System.Security.Permissions.ReflectionPermissionFlag.TypeInformation.
Type Reason System.Reflection.AmbiguousMatchException More than one method matching the specified criteria was found. ArgumentNullException name is null.
The following System.Reflection.BindingFlags are used to define which members to include in the search:
- Specify either System.Reflection.BindingFlags.Instance or System.Reflection.BindingFlags.Static to get a return value other than null.
- Specify System.Reflection.BindingFlags.Public to include public members in the search.
- Specify System.Reflection.BindingFlags.NonPublic to include non-public members (that is, private and protected members) in the search.
The following System.Reflection.BindingFlags values can be used to change how the search works:
- System.Reflection.BindingFlags.DeclaredOnly to search only the members declared in the type, not members that were simply inherited.
- System.Reflection.BindingFlags.IgnoreCase to ignore the case of name.
Note: For more information, see System.Reflection.BindingFlags.This version of Type.GetMethod(string, System.Reflection.BindingFlags, System.Reflection.Binder, System.Reflection.CallingConventions, Type[], System.Reflection.ParameterModifier[]) is equivalent to Type.GetMethod(string, System.Reflection.BindingFlags, System.Reflection.Binder, System.Reflection.CallingConventions, Type[], System.Reflection.ParameterModifier[])(name, bindingAttr , null, null, null).
If the current instance represents a generic type, this method returns the System.Reflection.MethodInfo with the type parameters replaced by the appropriate type arguments.
If the current instance represents an unassigned type parameter of a generic type or method, this method searches the methods of the class constraint, or the methods of object if there is no class constraint; the methods of all interface constraints; and the methods of any interfaces inherited from class or interface constraints.
Note: The name parameter cannot include type arguments.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0