Reputation: 3135
Is there any difference between System.Object.GetType()
and System.Type.GetType()
.
Upvotes: 1
Views: 2658
Reputation: 11397
System.Object.GetType()
- Gets the Type of the current instance.
E.g:
var s ="sdf".GetType() // Gets System.String
System.Type.GetType()
- Gets a Type object that represents the specified type
Type type = Type.GetType("System.Int32");
Upvotes: 0
Reputation: 108800
System.Type
is derived from System.Object
. As such it inherits the parameterless instance method GetType()
from System.Object
. It will give you the type of the subclass of Type
you got. And that's largely useless.
The static Type.GetType(string)
function and it's overloads are something different entirely, despite having the same name. They get you the type with a specific name.
Upvotes: 3
Reputation: 38210
Object.GetType()
gets the type of the current instance in which case it calls the Type.GetType
for self.
Upvotes: 1
Reputation: 14781
Yes there is ..
Read about System.Object.GetType and System.Type.GetType.
Upvotes: 1