Skip to main content

Posts

Showing posts from July, 2012

Difference between typeof() and GetType in c#

typeof() is used to get the type information from a type. Here type can be class, delegate, interface etc. e.g. Type t = typeof(Employee); GetType() is used to get the type information from the object. e.g. var obj = new Employee();        Type t = obj.GetType(); Thus, when you have an object you should use GetType function to extract Type information and when you have only a type with you then you should use typeof() operator to extract type information.