C# Programming/Keywords/virtual
The keyword virtual
is applied to a method declaration to indicate that the method may be overridden in a subclass. If the virtual
keyword is not applied and a method is defined in a subclass with the same signature as the one in the parent class, the method in the parent class is hidden by the subclass implementation. With other words, it is only possible to have a true polymorphism of functions with this keyword.
Notice: Comparing it with Java, a method is not virtual if and only if it is final
. This is the result of different design philosophies.
C# Keywords | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Special C# Identifiers (Contextual Keywords) | |||||||||||||||
| |||||||||||||||
Contextual Keywords (Used in Queries) | |||||||||||||||
|