This documentation is archived and is not being maintained.

Binder.BindToMethod Method

Selects a method to invoke from the given set of methods, based on the actual arguments.

[Visual Basic]
Public MustOverride Function BindToMethod( _
   ByVal bindingAttr As BindingFlags, _
   ByVal match() As MethodBase, _
   ByRef args() As Object, _
   ByVal modifiers() As ParameterModifier, _
   ByVal culture As CultureInfo, _
   ByVal names() As String, _
   <Out()> ByRef state As Object _
) As MethodBase
[C#]
public abstract MethodBase BindToMethod(
 BindingFlags bindingAttr,
 MethodBase[] match,
   ref object[] args,
 ParameterModifier[] modifiers,
 CultureInfo culture,
 string[] names,
   out object state
);
[C++]
public: virtual MethodBase* BindToMethod(
 BindingFlags bindingAttr,
 MethodBase* match[],
 Object* args __gc[],
 ParameterModifier modifiers[],
 CultureInfo* culture,
 String* names __gc[],
   [
   Out
] Object** state
) = 0;
[JScript]
public abstract function BindToMethod(
   bindingAttr : BindingFlags,
 match : MethodBase[],
 args : Object[],
 modifiers : ParameterModifier[],
 culture : CultureInfo,
 names : String[],
 state : Object
) : MethodBase;

Parameters

bindingAttr
One of the BindingFlags enumerators.
match
The set of methods Reflection has determined to be a possible match, typically because they have the correct member name.
args
The actual arguments passed in. Both the types and values of the arguments can be changed.
modifiers
An array of parameter modifiers that enable binding to work with parameter signatures in which the types have been modified.
culture
An instance of CultureInfo used to control the coercion of data types. If culture is a null reference (Nothing in Visual Basic), the CultureInfo for the current thread is used.
Note   For example, this parameter is necessary to convert a String that represents 1000 to a Double value, since 1000 is represented differently by different cultures.
names
The method name or names.
state
A binder-provided object that keeps track of argument reordering. The state parameter is a cookie that was passed to BindToMethod and represents an opaque object. The binder creates this object, and the binder is the sole consumer of this object. If state is not a null reference (Nothing in Visual Basic) when BindToMethod returns, the runtime calls ReorderArgumentArray.

Return Value

A MethodBase object containing the matching method.

Remarks

The binder allows a client to map the array of arguments back to its original form if the argument array has been manipulated by BindToMethod. Use this remap capability to get back by-reference arguments when such arguments are present. However, to get back by-reference arguments, you must be able to ensure that the argument order you used has not changed. When you pass arguments by name, the binder reorders the argument array, and that is what the calling methods see. The state parameter keeps track of argument reordering, thus enabling the binder to reorder the argument array to its original form.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Binder Class | Binder Members | System.Reflection Namespace | MethodBase

Show: