Object is the base class for all data types in C#. The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). The object is an alias for System.Object class.
When a value type is converted to object type, it is called boxing and on the other hand, when an object type is converted to a value type, it is called unboxing.
The following is an example showing the usage of object data types −
using System;
using System.IO;
namespace Demo {
class objectClass {
public int x = 56;
}
class MyApplication {
static void Main() {
object obj;
obj = 96;
Console.WriteLine(obj);
obj = new objectClass();
objectClass newRef;
newRef = (objectClass)obj;
Console.WriteLine(newRef.x);
}
}
}