In this article, I’ll explain how virtual, override and new keywords are different from each other by taking some examples as give below. The virtual keyword is used to modify a method, property, indexer, or events declared in the base class and allow it to be overridden in the derived class. The override keyword is used to extend or modify a virtual/abstract method, property, indexer, or event of base class into derived class. The new keyword is used to hide a method, property, indexer, or event of base class into derived class. Virtual and Override keywords are used in method overriding concept while new keyword is used in method overloading concept. Virtual and Override keywords are also called run-time polymorphism while new keyword is called compile-time polymorphism. Virtual and Override keywords cause late binding while new keyword causes early binding. Method Overriding ( Virtual and Override Keyword ) - For overriding the base class m...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers