C # Abstract (Interface)

Source: Internet
Author: User


 

Class

Abstract class)

Interface)

Method implementation

Either implemented or not

Not Allowed

Not Implemented

Member variables

Yes

Yes

None

Instantiation

Yes

No

No

Inheritance

It can inherit one class and multiple interfaces.

It can inherit one class and multiple interfaces.

Multiple Interfaces can be inherited (merged)

Member Functions

Yes

There are unimplemented member functions

Unimplemented member functions

Abstraction

 

Is feature abstraction

Is the abstraction of behavior









  

 

Interface(Interface) is a variant of the abstract class. all methods in the interface are abstract. multi-inheritance can be achieved by implementing such an interface. all methods in the interface are abstract, and no program question exists. The interface can only define static final member variables. the implementation of an interface is similar to that of a subclass, except that the implementation class cannot inherit behaviors from the interface definition. when a class implements a special interface, it defines all the methods of this interface. then, he can call the interface method on any object that implements the interface class. abstract classes allow the use of interfaces as reference variable types.

Abstract classClasses that declare some methods rather than implementation are called abstract classes. They are mainly used to create classes with basic behaviors and declare methods for classes, but cannot create instances for them. you can create a variable and point it to an instance of a specific subclass. it cannot be an abstract constructor or an abstract static method. abstract classes provide implementation for all Abstract methods in their parent classes, otherwise they are also Abstract classes. this abstract method is implemented in the subclass. other classes that know their behavior can implement these methods in the class.

Related Article

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.