The following C# snippet:
int x = 10;
ref int y = ref x;
is compiled to this IL:
.locals init (
[0] int32 x,
[1] int32& y
)
ldc.i4.s 10
stloc.0
ldloca.s 0
stloc.1
ret
How do I create a local of type int32& using ILGenerator?
I looked at the ILGenerator.DeclareLocal() method, but did not find a suitable overload.
By-reference locals are just locals with different type. To make type by-ref, you should call
.MakeByRefType()