asp net 3.5unleashed

Page 289

Int32[] arr = new Int32[] { 1, 2, 3, 4, 5 };

for (Int32 x = 0, n = arr.Length; x <= n; x++) { Console.WriteLine(arr[x]); } } } If you build this and use ILDasm.exe to examine the IL code, you’ll see the following: .method private hidebysig static void

Main() cil managed

{ .entrypoint // Code size .maxstack

43 (0x2b)

3

.locals init ([0] int32[] arr, [1] int32 x, [2] int32 n)

// Construct an array of five Int32 elements. IL_0000:

ldc.i4.5

IL_0001:

newarr

[mscorlib]System.Int32

// Initialize the array’s elements with values stored in metada ta. IL_0006:

dup

IL_0007:

ldtoken

field valuetype

’<PrivateImplementationDetails>‘/’$$struct0x6000001-1' ’<PrivateImplementationDetails>‘::’$$method0x6000001-1' IL_000c:

call

void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers :: InitializeArray(class [mscorlib]System.Array, valuetype [mscorlib]System.RuntimeFieldHandle) // Save the reference to the array in the arr variable. IL_0011:

stloc.0

// Initialize x to 0 IL_0012:

ldc.i4.0

IL_0013:

stloc.1

// Initialize n to the length of arr.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.