読書メモ:第3章 演算子
typeof
typeofは型にしか使えない。変数については GetType()を使う模様。
class Test { public static void Main() { object[] a = new object[5]; a[0] = (byte)1; a[1] = 123UL; a[2] = "abc"; a[3] = new object(); foreach (object x in a) { if (x != null) { System.Console.WriteLine("type: {0}, value: {1}", x.GetType(), x); } } } }