1 // Compiler options: -optimize 2 3 using System; 4 using System.Reflection; 5 6 public class C 7 { Test(T[] t)8 public static int Test<T> (T[] t) 9 { 10 // Has to include readonly. prefix 11 return t[0].GetHashCode (); 12 } 13 TestExtra(T[,] t)14 public static int TestExtra<T> (T[,] t) 15 { 16 // Has to include readonly. prefix 17 return t[0, 0].GetHashCode (); 18 } 19 Main()20 public static int Main () 21 { 22 Test (new[] { 2.1, 4.5 }); 23 Test (new[] { "b" }); 24 25 var body = typeof (C).GetMethod ("Test").GetMethodBody (); 26 27 // Check for readonly. (0xFE1E) 28 var array = body.GetILAsByteArray (); 29 if (array[2] != 0xFE) 30 return 1; 31 32 if (array[3] != 0x1E) 33 return 1; 34 35 return 0; 36 } 37 } 38