FieldAccessorGetInstanceValueTInstance, TField(TInstance) Method

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

Definition

Namespace: KGySoft.Reflection
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public TField GetInstanceValue<TInstance, TField>(
	 in TInstance instance
)
where TInstance : struct, new()

Parameters

instance  TInstance
The instance that the field belongs to.

Type Parameters

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

Return Value

TField
The value of the field.

Exceptions

InvalidOperationExceptionThis FieldAccessor represents a static field or a field of an open generic type.
ArgumentExceptionThe type arguments are invalid.
NotSupportedExceptionOn .NET Framework the code is executed in a partially trusted domain with insufficient permissions.

See Also