Skip to main content

What is method shadowing?

Mid C#
Quick Answer Shadowing is when a derived class defines a method with the same signature as the base class using the new keyword รขโ‚ฌโ€ not override. Call via a derived reference and you get the derived version; call via a base reference and you get the base version. Usually a code smell; prefer override.

Answer

Method shadowing occurs when a derived class hides a method from the base class using the new keyword.

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