Tip
To preserve the changes of a mutable value type embed it into a variable of Object type and pass it to the instance parameter of this method.
public static bool TrySetField(
Object instance,
string fieldName,
Object? value,
ReflectionWays way = ReflectionWays.Auto
)
Public Shared Function TrySetField (
instance As Object,
fieldName As String,
value As Object,
Optional way As ReflectionWays = ReflectionWays.Auto
) As Boolean
public:
static bool TrySetField(
Object^ instance,
String^ fieldName,
Object^ value,
ReflectionWays way = ReflectionWays::Auto
)
static member TrySetField :
instance : Object *
fieldName : string *
value : Object *
?way : ReflectionWays
(* Defaults:
let _way = defaultArg way ReflectionWays.Auto
*)
-> bool
fieldName can refer public and non-public fields.
If you already have a FieldInfo instance use the SetField(Object, FieldInfo, Object, ReflectionWays) method for better performance.
If way is Auto, then the DynamicDelegate way will be used.