Here are a few key rules for working with override methods:
- An override method must have the same signature as the virtual method it overrides. This includes the same name, parameter types, return type, and accessibility.
- An override method can change the accessibility of the virtual method to a more accessible type, but not to a less accessible type. For example, it can change public to protected but not the other way around.
- You cannot override a non-virtual method. Only virtual methods can be overridden.
- You cannot override a static method since static methods are not polymorphic.
- You cannot override a method if the derived class does not inherit the virtual method. The derived class must be related