About This eBook by Bart De Smet

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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( ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required