O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

System.Type

One of the main entry points to the reflection data is the System.Type type, which can be obtained through a variety of ways, one of which is the typeof operator in C#:

var stringType = typeof(string);var intType = typeof(int);

Both of those objects are of type System.Type (that is, you could substitute both uses of var with Type) and contain information about the capabilities of the said type. The uses of typeof in the preceding code translate into two instructions that map a token, which can be seen as a type name the runtime can look up in various data structures, onto the runtime object representing the type:

ldtoken   [mscorlib]System.Int32call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required