FieldAccessorSetInstanceValueTInstance, TField(TInstance, TField) Method

Sets the strongly typed value of an instance field in a reference type. If the type of the field or the declaring instance is not known at compile time the non-generic Set method can be used.

Definition

Namespace: KGySoft.Reflection
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public void SetInstanceValue<TInstance, TField>(
	TInstance instance,
	TField value
)
where TInstance : class

Parameters

instance  TInstance
The instance that the field belongs to.
value  TField
The value to set.

Type Parameters

TInstance
The type of the instance that declares the field.
TField
The type of the field.

Exceptions

InvalidOperationExceptionThis FieldAccessor represents a constant, a static field or a field of an open generic type.
ArgumentNullExceptioninstance is .
ArgumentExceptionThe type arguments are invalid.
NotSupportedExceptionOn .NET Framework the code is executed in a partially trusted domain with insufficient permissions.
PlatformNotSupportedExceptionYou use the .NET Standard 2.0 build of KGySoft.CoreLibraries and this FieldAccessor represents a read-only or a pointer field.

See Also