Code
.method public hidebysig static void Main() cil managed
{
.entrypoint
// 代码大小 41 (0x29)
.maxstack 3
.locals init (char[] V_0,
int32 V_1,
bool V_2)
IL_0000: nop
IL_0001: ldc.i4.5
IL_0002: newarr [mscorlib]System.Char
IL_0007: stloc.0
IL_0008: ldc.i4.0
IL_0009: stloc.1
IL_000a: br.s IL_0017
IL_000c: nop
IL_000d: ldloc.0
IL_000e: ldloc.1
IL_000f: ldc.i4.s 97
IL_0011: stelem.i2
IL_0012: nop
IL_0013: ldloc.1
IL_0014: ldc.i4.1
IL_0015: add
IL_0016: stloc.1
IL_0017: ldloc.1
IL_0018: ldc.i4.5
IL_0019: clt
IL_001b: stloc.2
IL_001c: ldloc.2
IL_001d: brtrue.s IL_000c
IL_001f: ldloc.0
IL_0020: ldc.i4.3
IL_0021: ldelem.u2
IL_0022: call void [mscorlib]System.Console::WriteLine(char)
IL_0027: nop
IL_0028: ret
} // end of method ILDemo::Main
这是《你必须知道的.NET》书中讲解newarr指令的一点代码
书中前面已经提到过
IL_00001: ldc.i4.5
这句的意思是将整数5作为一个4字节整数入栈。
可是在这里却又解释为 将5个4字节长度整数压入栈顶。(109页3行)
这是为何。
我觉得是不是这里应该是 将整数5入栈,然后作为newarr指令的参数 生成5个长的Char数组 ???
求证一下。不知我理解的对不对