Object classes in C#

WBOY
Release: 2023-09-13 09:21:09
forward
431 people have browsed it

C# 中的对象类

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

Methods and instructions ##3 4 5 6 7 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"); } } }
Copy after login

Output

Details: Website Tabs: Product Tabs: Services Tabs: Tools Tabs: Plugins
Copy after login

The above is the detailed content of Object classes in C#. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!