Difference between GetType() and typeof()

Why provide Microsoft two different methods for single work

4/1/2020 9:44:58 AM

Shashank Mishra

2 Answers

New Answer


Read: https://stackoverflow.com/questions/11312111/when-and-where-to-use-gettype-or-typeof https://stackoverflow.com/questions/983030/type-checking-typeof-gettype-or-is


First of all, Typeof is not a function. It is a keyword which is used to define the type. While GetType() is used to get the datatype of a particular object. It can be used only on the object of a class. For further learning, you can refer the following link. https://www.c-sharpcorner.com/blogs/difference-between-typeof-and-gettype-methods1