Answer:
typeof and Type.GetType both help us to get Type Information using Reflection.
Differences:
typeof:
1)typeof expects only an existent typename.
2)Namespace reference is not needed.
3)typename is verified at the compile time itself
ex: Type t=typeof(Program);
Type.GetType
1))we have to specify a typename, which will be checked at runtime only.
if it does not exist, an exception will be generated.
2)Namespace is needed before the type name
ex: Type t=Type.GetType("System.String");
Asked In: Many Interviews |
Alert Moderator