Difference between Type.GetType() and Object.GetType()

 Posted by Ddd on 1/22/2011 | Category: C# Interview questions | Views: 4948 | Points: 40

Both methods are used for extracting datatype related information and are defined in Type

and Object classes.

Type.GetType() does not need a variable or object reference .It can be directly used.


DataTable dt = new DataTable();
dt.Columns.Add("eno", Type.GetType("System.Int32"));
dt.Columns.Add("ename", Type.GetType("System.String"));

Object.GetType(): needs a variable or an object reference,
int a=30;
//int is indirectly derived from the Object class.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response