Tip
If you know the type of the field at compile time (and also the declaring type for instance fields),
then you can use the generic SetStaticValue
or SetInstanceValue methods for better performance.
public void Set(
Object? instance,
Object? value
)
Public Sub Set (
instance As Object,
value As Object
)
public:
void Set(
Object^ instance,
Object^ value
)
member Set :
instance : Object *
value : Object -> unit
Setting the field for the first time is slower than the System.Reflection.FieldInfo.SetValue method but further calls are much faster.
InvalidOperationException | This FieldAccessor represents a constant field or a field of an open generic type. |
ArgumentNullException | This FieldAccessor represents an instance field and instance is -or- This FieldAccessor represents a value type field and value is . |
ArgumentException | The type of instance or value is invalid. |
NotSupportedException | On .NET Framework the code is executed in a partially trusted domain with insufficient permissions. |
PlatformNotSupportedException | You use the .NET Standard 2.0 build of KGySoft.CoreLibraries and this FieldAccessor represents a read-only field. |