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( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access