I was looking at the metadata for Type, and noticed a member was protected, which made me wonder what might derive from it, which made me realize I could write a class that derives from it, and all that makes me wonder what I can do with that (if anything).
No compiler error from following:
class MyType : Type
{
// Implemented abstract members here.
}
Great question. I only have a partial answer. There are currently 4 classes that derive from Type. You can find the Type hierarchy on MSDN.
It looks like those types are basically used to encapsulate some “instance-building” logic. But I haven’t explored the code.
Edit
Oh, wow… that’s interesting. The code examples seem to not only be creating instances of types, but also classes themselves. Therefore, some of these classes are creating CLR types, and saving them off to real assemblies. That’s pretty cool.
Edit Again
Some of the big dogs have said that there are more than the four types I listed above. I used
ReflectorReSharper to find the derived types and found these (there could still be types missing):Edit Once More
as @MarcGravell stated, there’s really no reason why you would want to derive a class from any of these. You could, however, use them within a class of your own to encapsulate your own logic.