The result of both are exactly the same in your case. It will be your custom type that derives from System.Type
. The only real difference here is that when you want to obtain the type from an instance of your class, you use GetType
. If you don't have an instance, but you know the type name (and just need the actual System.Type
to inspect or compare to), you would use typeof
.
Important difference
EDIT: Let me add that the call to GetType
gets resolved at runtime, while typeof
is resolved at compile time.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…