+ 1
In C# langage .. When do we use the keywords #virtual #override #new .. What is the defference between them
as i know in the base classe we declare the methodes using virtual .. and in the methodes of derived classes we use override and new .. but what is the defference between them 😳
1 ответ
+ 4
in a very simple and short way: if you want the derived class redefine a method (replaces the method in base class with the method in derived class) use the virtual/override modifiers (virtual in base class and override in derived class). but if you want to use the base class method, use the new modifier in derived class.
just be carefull of relations between classes in polymorphisms.