C# inheritance
-
Hi, How can I make a subclass not inherit its parent class method (not by private keyword), but the parent class method need to be with public keyword, coz it allow other to access it ? Thanks
you can do this public new void myMethod(); That hides the base method and replaces it with a new method on the child. You can't make a child class not impliment a method that is public on the base class, and doing so would make no sense at all. Even if you impliment the method via an interface, you will inherit it. Christian Graus - Microsoft MVP - C++
-
Hi, How can I make a subclass not inherit its parent class method (not by private keyword), but the parent class method need to be with public keyword, coz it allow other to access it ? Thanks
You can't prevent the method from being inherited by the derived class, but if that method is virtual, you can prevent it from being overridden in the derived class by using the sealed[^] keyword. Regards Senthil _____________________________ My Blog | My Articles | WinMacro