C # differences between override and new

Source: Internet
Author: User

I didn't want to take this title, but I decided to use it considering Seo issues. The difference between override and new can be found in many other blogs. Here I will give you a rough list:

Override overwrites the virtual method, so there is only the method after rewriting;
New hides the method of the base class. The method of the base class and the method of the current class are hidden at the same time.

Here I want to express the concept of hiding, rewriting, and overloading in Object-Oriented objects. These concepts are often mentioned when we discuss object-oriented.

Hide: New

Rewrite: override

Overload: in fact, it is a method of multiple implementation methods, but the method name is the same

Public class transport
{
Public Transport (){}
Public Virtual void go (){}
Public Virtual void go (Road ){}
}
Public class car: Transport
{
Public override void go ()
Public new void go (Road ){}
}

You can take a closer look at the go method, as mentioned in the above three forms. After reading this, you should know how to express the object orientation hiding, rewriting, and overloading.

-- = Happy reading = --

Google Tag: overrid, new, rewrite, reload, hide

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.