Features and uses of abstract classes and abstract methods in C # [completely resolved]

Source: Internet
Author: User
// Abstract method: it only contains the method definition, but does not have a specific implementation method. It must be implemented by its subclass or subclass.
// Static methods cannot be marked as override, virtual, or abstract. That is, static methods must be specific.
/Abstract class: a class that contains one or more abstract methods is called an abstract class. When declaring a class, you must add the "abstract" keyword before the class name.
// The abstract class can contain non-abstract methods.
// The abstract class cannot be instantiated because it contains methods without specific implementation. The class that can be instantiated must not be an abstract class, but does not contain abstract methods that are not specifically implemented.
// After the subclass inherits the abstract parent class, you can use the override keyword to overwrite the abstract methods in the parent class and perform specific implementation. You can also leave the abstract method to future generations for implementation. The subclass is still an abstract class and must be declared as abstract
// The inherited abstract method cannot be hidden.
// Hide: Create a method in the subclass with the same signature as the method in the parent class (same method name, same parameter list-parameter type and order) methods (with the keyword "virtual" or "Override") can be implemented, but we recommend that you use the "new" keyword to explicitly hide it.
// Only the "Override" keyword can be used to overwrite (override) Methods marked as "virtual", "abstract", or "Override" in the parent class, and the method marked as override in the subclass, it must also be the method marked as "virtual", "abstract", or "Override" in the parent class.
// Override: the override keyword must be used. methods that can be overwritten include methods marked as abstract, virtual, and override;
// Hide: You can use the new keyword or the keyword. methods that can be hidden include general methods and methods marked as virtual "or" Override;
// Overload: no special keywords are required.
// Static methods can be hidden or overloaded.

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.