What is the difference between override, new, and
virtual keywords?
What is the difference between override, new, and virtual keywords?
200
19-Jun-2025
Ponu Maurya
24-Jun-2025In 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