- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- What are enumerated data types in C++?
- What are pointer data types in C#?
- What are nullable data types in C#?
- What are dynamic data types in C#?
- What are reference data types in C#?
- What are the data types, value types and reference types in C#?
- What are fundamental data types in C++ programming?
- What are user defined data types in C#?
- What are primary data types in C language?
- What are string and String data types in C#?
- What are different types of data in C language?
- What are the different data types of arrays in C#?
- What are primitive data types in Java?
- What are reference data types in Java?
- What are primitive data types in JavaScript?

Advertisements