Abstract class
The abstract modifier can be used with classes, methods, properties, indexers, and events.
1. Abstract classes cannot be instantiated.
2. Abstract classes can contain abstract methods and abstract accessors.
3. Abstract classes cannot use the sealed modifier, and this modifier prevents other classes from inheriting from the class.
4. A non-abstract class derived from an abstract class must include all inherited abstract methods and the implementation of an abstract accessor.
5, the abstract method cannot be private.
6. Abstract methods must be declared in an abstract class.
7. The abstract method cannot contain a method body, only the method body can be overridden in a derived class.
8. Static and virtual modifiers cannot be used in abstract method declarations.
9. Overriding the implementation in a derived class, you must add the keyword override.
Abstract class Count_adstract//Abstraction classes { protected string A; protected string B; Protected Count_adstract (String A, string b) { a = A; b = b; } Public abstract string Count_adstract_method (); Abstract method } class count:count_adstract {public Count (string A, string b): Base (A, B) {} Public Override string Count_adstract_method ()//method override { return A + B; } Class program { static void Main (string[] args) { count c = new Count ("SSS", "ddd"); Console.WriteLine (C.count_adstract_method ()); Console.readkey ();}}}
C # Abstract classes and abstract method implementations