Objects in C#

(Almost) Everything is an object is .net and C#. We all know that int, char, string, date, double etc are the primitive data types. But all these data types are derived from system.object.

To understand this lets take an example of int data type. We all know that int is derived from System.Int32; but we can declare the variable of int type using below mentioned two ways

int i = new int();
int j = 0;

where first option is like abject instance creation. When we use the . (dot) operator on i then it will give us different methods like .ToString(), .Equals() for object equality, .GetType() to get type. Hence this proves that all these primitives data types also derived from object (system.object) base class.

datatype