Skip to main content

Posts

Showing posts from February, 2020

What are C# Virtual and Non-Virtual Method

  C# Virtual and Non-Virtual Method In Microsoft.net C# Virtual method supports polymorphism, which is part of the OOP Concept. We would combined virtual and override keyword with the virtual keyword on the parent/base class and then use the override keyword on the method in the child/derive class and both methods are virtual. Any methods which do not have virtual or override keyword or that have new keyword are non-virtual method. When a virtual method is invoked on an object, the run-time type of the object is used to determine which implementation of the method to use. When a non-virtual method is invoked on an object the compile-time type of object is used to determine which implementation of the method to use.