Skip to main content

What is the purpose of the new keyword in method definitions?

Senior C#
Quick Answer The new keyword in a method definition intentionally hides an inherited member, suppressing the compiler warning about shadowing. It signals deliberate hiding rather than accidental name collision. Use it rarely รขโ‚ฌโ€ prefer override for proper polymorphic behavior.

Answer

The new keyword hides an inherited member intentionally, preventing compiler warnings and signaling deliberate shadowing behavior.

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