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
- name
Type: System. . :: . .String
The string containing the name of the method to get.
- bindingAttr
Type: System.Reflection. . :: . .BindingFlags
A bitmask comprised of one or more BindingFlags that specify how the search is conducted.
-or-
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).
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.