Binder.BindToField Method

Selects a field from the given set of fields, based on the specified criteria.

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

public abstract FieldInfo BindToField (
	BindingFlags bindingAttr,
	FieldInfo[] match,
	Object value,
	CultureInfo culture
)
public abstract FieldInfo BindToField (
	BindingFlags bindingAttr, 
	FieldInfo[] match, 
	Object value, 
	CultureInfo culture
)
public abstract function BindToField (
	bindingAttr : BindingFlags, 
	match : FieldInfo[], 
	value : Object, 
	culture : CultureInfo
) : FieldInfo
Not applicable.

Parameters

bindingAttr

A bitwise combination of BindingFlags values.

match

The set of fields that are candidates for matching. For example, when a Binder object is used by System.Type.InvokeMember, this parameter specifies the set of fields that reflection has determined to be possible matches, typically because they have the correct member name. The default implementation provided by Type.DefaultBinder changes the order of this array.

value

The field value used to locate a matching field.

culture

An instance of CultureInfo that is used to control the coercion of data types, in binder implementations that coerce types. If culture is a null reference (Nothing in Visual Basic), the CultureInfo for the current thread is used.

NoteNote:

For example, if a binder implementation allows coercion of string values to numeric types, this parameter is necessary to convert a String that represents 1000 to a Double value, because 1000 is represented differently by different cultures. The default binder does not do such string coercions.

Return Value

The matching field.

Exception typeCondition

AmbiguousMatchException

For the default binder, bindingAttr includes BindingFlags.SetField, and match contains multiple fields that are equally good matches for value. For example, value contains a MyClass object that implements the IMyClass interface, and match contains a field of type MyClass and a field of type IMyClass.

MissingFieldException

For the default binder, bindingAttr includes BindingFlags.SetField, and match contains no fields that can accept value.

NullReferenceException

For the default binder, bindingAttr includes BindingFlags.SetField, and match is a null reference (Nothing in Visual Basic) or an empty array.

-or-

bindingAttr includes BindingFlags.SetField, and value is a null reference (Nothing in Visual Basic).

If bindingAttr does not include BindingFlags.SetField, the default binder implementation provided by Type.DefaultBinder simply returns the first element of match. No selection is done.

This method controls the binding provided by Type.InvokeMember.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show: