Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What is Virtual Method in C#?

user-image
Question ajoutée par Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
Date de publication: 2016/10/20
Hassan Elsherbiny
par Hassan Elsherbiny , .Net Developer , Al-dar international

when you create a method as virtual you can use it as it is in the sub classes(classes inherits from the original class containing the method)or Override it to define another behavior for this method for this class only (the child class)

Mohannad Bakbouk
par Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb

A virtual method is a method that can be redefined in derived classes. A virtual method has an implementation in a base class as well as derived the class. It is used when a method's basic functionality is the same but sometimes more functionality is needed in the derived class. A virtual method is created in the base class that can be overridden in the derived class. We create a virtual method in the base class using the virtual keyword and that method is overridden in the derived class using the override keyword.

More Questions Like This