5th abstracts and 5th
IAbstract class
Describe a thing. Because there is not enough information, this thing is called an abstract thing. Abstract is an abstract keyword. The declared class is called an abstract class, and the declared method is called an abstract method.
Abstract attributesThe Declaration does not provide the Implementation of the attribute accessors. It only declares the attributes supported by the class, and the implementation of the accessors is left to the derived class.
Abstract MethodThe Declaration does not provide the Implementation of The method. It must be an empty method and leave the method implementation to the derived class. The derived class must overload the abstract methods of the abstract base class.
Abstract classIt is used as a base class and cannot be directly instantiated, that is, it cannot be used to create objects with abstract classes. Abstract classes are used to provide public definitions of the base classes that can be shared by multiple Derived classes. Abstract class features:
IISeveral questions about abstract classes
1.Is there any constructor in the abstract class?
Yes.Although the constructor of an abstract class cannot instantiate an abstract class object, it cannot create an object, but the abstract class has a subclass. The constructor of an abstract class can be used to instantiate a subclass object.
2.Must an abstract class be a parent class?
Yes.The subclass must overwrite the abstract method before instantiation.
3.Can abstract classes not define abstract methods?
Yes.
4.Abstract keywords abstractAnd which keywords cannot coexist?
Sealed, Private, static.First, the abstract class cannot be sealed or static. The second reason is that virtual and abstract members cannot be private.
3.Differences between abstract classes and interfaces
Note: For details about interfaces, refer to "6th interfaces"