Atulya Panda
Write the difference between TypeOf and GetType?
Posted by Atulya Panda in .Net | C# on Nov 26, 2012
  • 0
  • 2
  • 1190
Do you know the answer for this question? Post it below.
Guest
Posted by Manoj Kumar on Nov 29, 2012
  • 2

typeof is used to get the type based on a class. That means if you use typeof with object, it will gives you error. You must pass class as parameter parameter. Where GetType is used to get the type based on an object (an instance of a class). Means GetType needs parameter of object rather than class name.

Posted by Atulya Panda on Nov 26, 2012
  • 1

Both of them produce the same information. The difference lies that from where the information is got. typeOf is used to get the type based on class. It will give an error if typeOf is used with the object. GetType is used get the type based on object, which states that geType needs parameter of object.


SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts
PRIVACY POLICY | TERMS & CONDITIONS | SITEMAP | CONTACT US | ABOUT US | REPORT ABUSE
2013© C# Corner. All contents are copyright of their authors.