Click here to Skip to main content
15,905,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Public Class Manager
    Inherits Employee
    Public Overrides Sub Salary()
      ' MyBase.Salary
      ' I want to call Person.Salary instead of Employee Salary, is this possible. How can i call the base base class from the top Inherits class.
    End Sub
End Class

Public Class Employee
    Inherits Person

    Public Overrides Sub Salary()
      ' has many logic to calcuate for employee
    End Sub
End Class

Public Class Person
   Public Overridable Sub Salary()
      ' has many logic to do calculate for person
   End Sub

End Class
Posted

C#
public class Person
{
    public virtual void Salary()
    {

    }
}

public class Employee : Person
{
    public override void Salary()
    {
        // Person.Salary
        base.Salary();
    }
}

public class Manager : Employee
{
    public override void Salary()
    {
        // Employee.Salary
        base.Salary();
    }
}


If you don't want one class to call its base class method it is up to you to implement the logic.
 
Share this answer
 
There is no language supported way to do this.

You could add a separate protected function to the Person class that calls it's Salaray function and call that from the Manager class. You would need to make sure that a function with the same name was never defined in the Employee class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900