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

WBOY
Release: 2023-09-04 23:49:02
forward
1206 people have browsed it

C# 中的重写和隐藏有什么区别?

Here are the differences between overriding and hiding -

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

  • In an override, you can access the base class using the object overridden method of the subclass. Shadow cannot access subclass methods.

  • Shading is also called method hiding. 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.

  • Under override, you can define behavior specific to the subclass type, which means that the subclass can implement the parent class methods as per its requirements.

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!