_FieldInfo.SetValue Method

Definition

Provides COM objects with version-independent access to the SetValue methods.

Overloads

SetValue(Object, Object)

Provides COM objects with version-independent access to the SetValue(Object, Object) method.

SetValue(Object, Object, BindingFlags, Binder, CultureInfo)

Provides COM objects with version-independent access to the SetValue(Object, Object, BindingFlags, Binder, Object[], CultureInfo) method.

Remarks

This method is for access to managed classes from unmanaged code, and should not be called from managed code.

The SetValue methods set the value of the field for the given object to the given value.

SetValue(Object, Object)

Provides COM objects with version-independent access to the SetValue(Object, Object) method.

public void SetValue (object obj, object value);

Parameters

obj
Object

The object whose field value will be set.

value
Object

The value to assign to the field.

Remarks

This method is for access to managed classes from unmanaged code, and should not be called from managed code.

The SetValue method sets the value of the field supported by the given object.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

SetValue(Object, Object, BindingFlags, Binder, CultureInfo)

Provides COM objects with version-independent access to the SetValue(Object, Object, BindingFlags, Binder, Object[], CultureInfo) method.

public void SetValue (object obj, object value, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture);

Parameters

obj
Object

The object whose field value will be set.

value
Object

The value to assign to the field.

invokeAttr
BindingFlags

A field of Binder that specifies the type of binding that is desired (for example, Binder.CreateInstance or Binder.ExactBinding).

binder
Binder

A set of properties that enables the binding, coercion of argument types, and invocation of members through reflection. If binder is null, then Binder.DefaultBinding is used.

culture
CultureInfo

The software preferences of a particular culture.

Remarks

This method is for access to managed classes from unmanaged code, and should not be called from managed code.

The SetValue method sets the value of the field supported by the given object.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1