Abstract
The abstract modifier can be used with classes, methods, properties, indexers, and events.
Use the abstract modifier in a class declaration to indicate that a class can only be a base class for other classes.
An abstract class has the following attributes:
• Abstract classes cannot be instantiated.
• Abstract classes can contain abstract methods and abstract accessors.
• An abstract class cannot be modified with the sealed modifier, which means that the class cannot be inherited.
• A non-abstract class derived from an abstract class must include the actual implementation of all inherited abstract methods and abstract accessors.
• Use the abstract modifier in a method or property declaration to indicate that this method or property does not contain an implementation.
Abstract methods have the following characteristics:
• Abstract methods are implicit virtual methods.
• Only abstract method declarations are allowed in abstract classes.
• There is no method body because the abstract method declaration does not provide a real implementation, and the method declaration ends with a semicolon and does not have braces ({}) after signing. For example: Public abstract void MyMethod ();
• Implementation is provided by the overriding method, which is a member of a Non-abstract class.
• It is an error to use a static or virtual modifier in an abstract method declaration.
Abstract properties behave like abstract methods, except for differences in declaration and invocation syntax.
• It is an error to use the abstract modifier on a static property.
• In a derived class, you can override an abstract inherited property by including a property declaration that uses the override modifier.
Virtual
The virtual keyword is used to modify the declaration of a method or property, in which case the method or property is called a virtual member. The implementation of a virtual member can be changed by an overriding member in a derived class.
When a virtual method is invoked, the Run-time type of the object is checked for the overriding member. The overridden member in most derived classes is called, and it may be the original member if no derived class overrides the member.
By default, the method is non-virtual. Non-virtual methods cannot be overridden.
You cannot use the virtual modifier with the following modifiers:
Static abstract override
The behavior of a virtual property is the same as an abstract method, except that the declaration and invocation syntax are different.
• It is an error to use the virtual modifier on a static property.
• You can override a virtual inheritance property in a derived class by including a property declaration that uses the override modifier.
Override (Overrides the above two keyword modification methods)