I want to create a multi-dimensional array using Reflection.Emit and set it's element. 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)
The IL code to create array:
newobj instance void int32[0..., 0...]::.ctor(int32, int32)
And the IL code to set the array's element:
call instance void int32[0..., 0...]::Set(int32, int32, int32)
What kind of IL Generator.Emit() code corresponding to those two IL sentence?