Skip to main content

What is a virtual method?

Mid C#
Quick Answer A virtual method has a default implementation in the base class but can be overridden by subclasses. Mark it virtual in the parent, use override in the child. If not overridden, the base version runs. This is the foundation of runtime polymorphism in C#.

Answer

A virtual method allows derived classes to override behavior and provide their own implementation.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice