 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are object data types in C#?
The object types can be assigned values of any other types, value types, reference types, predefined or user-defined types. However, before assigning values, it needs type conversion.
The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). 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 −
object obj; obj = 100; // this is boxing
Here is the complete example showing the usage of object data types −
Example
using System; using System.IO; namespace Demo {    class objectClass {       public int x = 200;    }    class MyApplication {       static void Main() {          object obj;          obj = 50;          Console.WriteLine(obj);          Console.WriteLine(obj.GetType());          Console.WriteLine(obj.ToString());              obj = new objectClass();          objectClass newRef;          newRef = (objectClass)obj;          Console.WriteLine(newRef.x);       }    } }  Output
50 System.Int32 50 200
Advertisements
 