What is the difference between override , new , and virtual keywords ?
What is the difference between override, new, and virtual keywords? Anubhav Sharma 709 19 Jun 2025 What is the difference between override, new, and virtual keywords?
In C#, the
virtual,override, andnewkeywords are used for method overriding and hiding in object-oriented inheritance. Here's a breakdown of each:virtualoverridevirtual,abstract, oroverride.newExample to Illustrate the Difference
Output:
Show()is overridden usingoverride, output:"Derived Show"Show()is hidden usingnew, output:"Base Show"(becauseobjis aBasereference)Summary Table
virtualoverridenew