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 structure, onto the runtime object representing the type:

image

Reflection allows us ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.