Home  >  Article  >  Backend Development  >  Object classes in C#

Object classes in C#

WBOY
WBOYforward
2023-09-13 09:21:09505browse

C# 中的对象类

The Object class is the base class for all classes in C#. It has the following methods on C#.

Methods and instructions##34567 tr>8
Sr.No
1 Equals(Object)

Determine whether the specified object is equal to the current object.

2 Equals(Object,Object,

Determines whether the specified object instance is Considered equal.

Finalize()Allow objects to try free resources

GetHashCode() Default hash function.

GetType()The type of the current instance.

MemberwiseClone()A shallow copy of the current object.

ReferenceEquals(Object,Object)Determine whether the specified Object instance is the same instance.

ToString()Returns a string representing the current object.

Let's look at an example of how to create an object of a class in C#.

Example

Live Demonstration

using System;
namespace MyApplication {
   class Demo {
      protected string name = "Website";
      protected void Display(string str) {
         Console.WriteLine("Tabs: " + str);
      }  
   }

   class Test : Demo {
      static void Main(string[] args) {
         Test t = new Test();
         Console.WriteLine("Details: " + t.name);
         t.Display("Product");
         t.Display("Services");
         t.Display("Tools");
         t.Display("Plugins");
      }
   }
}

Output

Details: Website
Tabs: Product
Tabs: Services
Tabs: Tools
Tabs: Plugins

The above is the detailed content of Object classes in C#. 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