GetMethod Method (String, BindingFlags)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Searches for the specified method, using the specified binding constraints.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

abstract GetMethod : 
        name:string * 
        bindingAttr:BindingFlags -> MethodInfo 
override GetMethod : 
        name:string * 
        bindingAttr:BindingFlags -> MethodInfo 


Type: System..::..String
The string containing the name of the method to get.
Type: System.Reflection..::..BindingFlags
A bitmask comprised of one or more BindingFlags that specify how the search is conducted.
Zero, to return nullNothingnullptrunita null reference (Nothing in Visual Basic).

Return Value

Type: System.Reflection..::..MethodInfo
An object representing the method that matches the specified requirements, if found; otherwise, nullNothingnullptrunita null reference (Nothing in Visual Basic).


IReflect..::..GetMethod(String, BindingFlags)

The following BindingFlags filter flags can be used to define which methods to include in the search:

  • You must specify either BindingFlags.Instance or BindingFlags.Static in order to get a return.

  • Specify BindingFlags.Public to include public methods in the search.

  • Specify BindingFlags.NonPublic to include non-public methods (that is, private, internal, and protected methods) in the search.

  • Specify BindingFlags.FlattenHierarchy to include public and protected static members up the hierarchy; private static members in inherited classes are not included.

The following BindingFlags modifier flags can be used to change how the search works:

  • BindingFlags.IgnoreCase to ignore the case of name.

  • BindingFlags.DeclaredOnly to search only the methods declared on the Type, not methods that were simply inherited.

See System.Reflection..::..BindingFlags for more information.

If the current T:System.Type represents a constructed generic type, this method returns the MethodInfo 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 methods of the class constraint, or the methods of Object if there is no class constraint.