ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What is Virtual Method in C#?

user-image
تم إضافة السؤال من قبل Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
تاريخ النشر: 2016/10/20
Hassan Elsherbiny
من قبل 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
من قبل 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.

المزيد من الأسئلة المماثلة