The typeof
operator is used to obtain the System.Type
object for a type.
The result of a typeof-expression is the System.Type
object for the indicated type.
The example
class Test { static void Main() { Type[] t = { typeof(int), typeof(System.Int32), typeof(string), typeof(double[]) }; for (int i = 0; i < t.Length; i++) { Console.WriteLine(t[i].Name); } } }
produces the following output:
Int32 Int32 String Double[]
Note that int
and System.Int32
are the same type.