Quantcast
Channel: Add onto method in parent class from inherited class - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by Mike G for Add onto method in parent class from inherited class

I see two problems here, one in your code sample and one in your understanding of how overriding works.Start() is already defined as a protected virtual method of the parent class. Your definition in...

View Article



Answer by Jalal Mostafa for Add onto method in parent class from inherited class

Add override keyword.protected override void Start(){ base.Start(); DoSomethingElse();}

View Article

Answer by Jakub Lortz for Add onto method in parent class from inherited class

You can use base to call the base class' implementation of Start(). You also have to override the virtual method in the child class:protected override void Start () { base.Start(); BlahBlahBlah();...

View Article

Add onto method in parent class from inherited class

Suppose that you have a function in the parent class, it does x and y. But now in the inherited class, you want to make the function also do z. You can't overwrite it because that would mean that the...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images