2 using System
.Reflection
;
4 unsafe public class C
{
9 C a
= new C { Value = 12 }
;
10 FieldInfo info
= typeof(C
).GetField("Value");
11 TypedReference reference
= __makeref(a
);
13 if (!(reference
is TypedReference reference0
))
14 throw new Exception("TypedReference");
16 info
.SetValueDirect(reference0
, 34);
18 Console
.WriteLine($"a.Value = {a.Value}");
20 throw new Exception("SetValueDirect");
23 if (CopyRefInt(ref z
) != 56)
24 throw new Exception("ref z");
26 Console
.WriteLine("ok");
29 static int CopyRefInt(ref int z
)
32 throw new Exception("CopyRefInt");