就够了。产生这种差异的缘由何在呢?别慌,马上就能看到。还有一点,c#中有foreach语句,这个语句与传统的for语句比较起来又如何呢?看下面,是上面的程序用ildasm反编译产生的(为了大家能看得更明白,我对反编译产生的il程序做了一些修改)。
.assembly array1{}
.class private auto ansi beforefieldinit array1
extends [mscorlib]system.object
{
.method public static void
{
.entrypoint
.maxstack 4
.locals init (int32[] v_0,//int[] number
int32 v_1,//i
int32 v_2,
int32[] v_3,//a pointer of array
int32 v_4)
ldc.i4.6//load int32 const 6(length of the array) onto the stack