As in the title, what is it and how does it differ from MethodTable?
1 Answers
mdToken is a metadata token, or more or less a row id in a metadata table (part of the int identifies the table it belongs to and the other part identifies the row in that table).
There are 2 types of tokens - internal and external.
Internal tokens are smaller than external and use only 4 bytes: 3 bytes for the row id and 1 byte for the table id. (I'm not sure if these sizes have changed for x64 but you get the idea) Example: 0x06000000 for the first row (zero based) in the Method table.
External tokens (or coded tokens) are bigger and are for a range of tables, not a specific table. There are several different coded token types and they have known schemas that you have to know to understand their coded values. For example the HasCustomAttribute token can be a token for any of 19 metadata tables (since attributes can be attached to so many different parts of your code). Part of the coded token is the id of the table also called a tag (but the bit width used to keep this part differs with each - hence the known schemas), the remaining part is left for the row id. Sizes of external tokens can vary - this helps keep the size smaller when the row counts are smaller.

- 3,770
- 18
- 22