20141214 -- abstract base class, interface, 20141214 -- abstract interface
Abstract class:
Adding the keyword "abstract" before a class becomes an abstract class.
Abstract class, which cannot be used as an object. (Not New) It is generally used to reference subclass objects,
Abstract class Man {public void shuohua () {Console. WriteLine ("English ");}}
Abstract method:
Adding the keyword "abstract" before a method becomes an abstract method.
public abstract void shuohua()
When a class inherits an abstract class, you must override the method. (Override keyword ),
Public override void shuohua () {Console. WriteLine ("English ");}
All abstract methods in the abstract class parent class must be implemented in the subclass.
Abstract methods must be in abstract classes.Other methods can appear in the abstract class, but the abstract methods must be in the abstract class.
A common method in an abstract class can only be used in the current class.
An abstract class can only be used as a parent class.You cannot create an object.
Abstract attributes:
It can only be used in abstract classes.
Interface:
Interface keyword
Right-click Add add new item Select Interface
Using System; using System. Collections. Generic; using System. Linq; using System. Text; using System. Threading. Tasks; namespace jicheng {interface Interface1 {}}
The interface cannot contain fields or methods.
An interface can be regarded as a pure abstract class. All its methods are abstract classes.It is mainly used to specify the method name,
Interface object. New must inherit the class of the interface:
Name of the interface type variable name = New inherits the name of the class of this interface ();