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)

Syntax

'Declaration
Public Function GetMethod ( _
    name As String, _
    bindingAttr As BindingFlags _
) As MethodInfo
public MethodInfo GetMethod(
    string name,
    BindingFlags bindingAttr
)
public:
virtual MethodInfo^ GetMethod(
    String^ name, 
    BindingFlags bindingAttr
) sealed
abstract GetMethod : 
        name:string * 
        bindingAttr:BindingFlags -> MethodInfo 
override GetMethod : 
        name:string * 
        bindingAttr:BindingFlags -> MethodInfo 
public final function GetMethod(
    name : String, 
    bindingAttr : BindingFlags
) : MethodInfo

Parameters

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).

Implements

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

Remarks

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.

.NET Framework Security

See Also

Reference

Type Class

GetMethod Overload

System Namespace