I want to create a multidimensional array using Reflection.Emit and set it. Like the following C # code:
int[,] nums = new int[2, 2]; nums[1, 1] = 2;
And turn into IL code:
IL_0000: nop IL_0001: ldc.i4.2 IL_0002: ldc.i4.2 IL_0003: newobj instance void int32[0..., 0...]::.ctor(int32, int32) IL_0008: stloc.0 IL_0009: ldloc.0 IL_000a: ldc.i4.1 IL_000b: ldc.i4.1 IL_000c: ldc.i4.2 IL_000d: call instance void int32[0..., 0...]::Set(int32, int32, int32)
IL code to create an array:
newobj instance void int32[0..., 0...]::.ctor(int32, int32)
And the IL code to set the array element:
call instance void int32[0..., 0...]::Set(int32, int32, int32)
Which IL Generator.Emit () code matches these two IL clauses?
c # emit
nineveh.Y
source share