Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 18760 |  Welcome, Guest!   Register  Login
 Home > Interview Questions > C# Interview Questions > Difference between typeof and Type.Get ...

Difference between typeof and Type.GetType

Interview question and answer by: Ddd | Posted on: 3/7/2011 | Category: C# Interview questions | Views: 2650 | | Points: 40
Ads
Ads


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 
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

Even more ... | Submit Interview Questions and win prizes!

More Interview Questions from Ddd

Even more ... | Submit Interview Questions and win prizes!


About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/20/2013 3:01:35 AM