Home  >  Article  >  Backend Development  >  What is the base class for all data types in C#.NET?

What is the base class for all data types in C#.NET?

王林
王林forward
2023-08-27 20:29:06663browse

C#.NET 中所有数据类型的基类是什么?

Object is the base class for all data types in C#. Object types are the ultimate base class for all data types in the C# Common Type System (CTS). This object is an alias for the System.Object class.

When a value type is converted to an object type, it is called boxing; on the other hand, when an object type is converted to a value type, it is called boxing. It's 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);
      }
   }  
}

The above is the detailed content of What is the base class for all data types in C#.NET?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:Deque class in C#Next article:Deque class in C#