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

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

王林
Release: 2023-08-27 20:29:06
forward
717 people have browsed it

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);
      }
   }  
}
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template