What is the difference between override, new, and
virtual keywords?
What is the difference between override, new, and
virtual keywords?
Student
The Anubhav portal was launched in March 2015 at the behest of the Hon'ble Prime Minister for retiring government officials to leave a record of their experiences while in Govt service .
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