Suresh Ravi

Suresh Ravi

  • NA
  • 114
  • 42.7k

Is there any difference b/w baseclass method hiding (using new) and overriding virtual methods??

Aug 31 2009 5:40 AM
Using the new keyword we are hiding the base methods implementation. using override we are overriding the base class method with a new implementation in derived class. For me both looks like the same. i dont feel any difference. Class Baseclass { public void mymethod() { my implementation } } Class Derived : BaseClass { new public void mymethod() { my new implemetation } } if i want to access base calss method, i can use BaseClass.mymethod() . if i want to access the new implementation i can use Derived.mymethod(). using the new, i am giving the new implementation to the same method instead of overriding. here what is the difference b/w new and override??

Answers (1)