Home  >  Article  >  Backend Development  >  What is the difference between overriding and hiding in C#?

What is the difference between overriding and hiding in C#?

PHPz
PHPzforward
2023-09-02 09:25:021448browse

C# 中的覆盖和隐藏有什么区别?

Method hiding in C# is also called hidden. The methods of the parent class are available to the child class without using the override keyword in the shadow. Subclasses have their own versions of the same functions.

Define behavior specific to the subclass type i.e. you in the override, this means that the subclass can implement the parent class method as per its requirement.

Hiding redefines the complete method, while overriding only redefines the implementation of the method.

In overriding, you can use the object overridden method of the subclass to access the base class. Shadow cannot access subclass methods.

The above is the detailed content of What is the difference between overriding and hiding 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