typeof: The typeof operator is used to obtain the System.Type object for a Type.
operator to obtain a System.Type object of a certain type.
Type t = typeof (int);
GetType: Gets The Type of the current instance.
method to get the type of the current instance .
int i = 10;
Console.WriteLine (I.gettype ());
Difference:
- Typeof () is an operator and GetType is a method
- GetType () is a method of the base class System.Object, so it can be called only after an instance is established (after initialization)
- Typeof () parameter can only be int,string,string, custom type, and cannot be an instance
- Both GetType () and typeof () return references to System.Type.
The difference between TypeOf () and GetType ():
(1) TypeOf (): Gets the type of a class
(2) GetType (): Gets the type of an instance of class
Override a method's predecessor is this method in the parent class: abstract or virtual, override
Original link: http://www.cnblogs.com/tangself/archive/2009/12/06/1617885.html
The difference between C # GetType and typeof