Breyta

Deila með


FieldBuilder.SetValue Method

Definition

Sets the value of the field supported by the given object.

public:
 override void SetValue(System::Object ^ obj, System::Object ^ val, System::Reflection::BindingFlags invokeAttr, System::Reflection::Binder ^ binder, System::Globalization::CultureInfo ^ culture);
public override void SetValue (object? obj, object? val, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder? binder, System.Globalization.CultureInfo? culture);
public override void SetValue (object obj, object val, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture);
override this.SetValue : obj * obj * System.Reflection.BindingFlags * System.Reflection.Binder * System.Globalization.CultureInfo -> unit
Public Overrides Sub SetValue (obj As Object, val As Object, invokeAttr As BindingFlags, binder As Binder, culture As CultureInfo)

Parameters

obj
Object

The object on which to access the field.

val
Object

The value to assign to the field.

invokeAttr
BindingFlags

A member of IBinder that specifies the type of binding that is desired (for example, IBinder.CreateInstance, IBinder.ExactBinding).

binder
Binder

A set of properties and enabling for binding, coercion of argument types, and invocation of members using reflection. If binder is null, then IBinder.DefaultBinding is used.

culture
CultureInfo

The software preferences of a particular culture.

Exceptions

This method is not supported.

Remarks

This method will assign the val parameter to the field reflected by this instance on Object obj. If the field is static, obj will be ignored. For non-static fields, obj should be an instance of a class that inherits or declares the field.

The new value is passed as an Object. For example, if the field's type is Boolean, an instance of Object with the appropriate Boolean value is passed. Before setting the value, SetValue checks to see if the user has access permission.

Access restrictions are ignored for fully-trusted code. Private constructors, methods, fields, and properties can be accessed and invoked using Reflection whenever the code is fully-trusted.

Note

This method is currently not supported. As a workaround, retrieve the FieldInfo by reflecting on the finished type and call SetValue to set the value of the field.

Applies to