خرید بک لینک

Vote count: 0

Who ya goa call? Unrelated code to pose the problem. Not the best editor tool so being terse. Thanks.

A new method that is part of the derived class caot be accessed by the new object. All the Intellisense sees are the abstract parts of the base class. Typing them in and ruing them gets an error. If methods and fields can't be added what is the point of base to derived and on down. I have searched all examples and come up empty.

public class SalesEmployee : Employee
{
    public decimal salesbonus; // Additional field

    public SalesEmployee(string name, decimal basepay, decimal salesbonus)
    {
        this.salesbonus = salesbonus; // Create new field
    }

    public override decimal CalculatePay() // Override abstract
    {
        retu basepay + salesbonus;
    }

    public decimal CalculateExtraBonus() // Not an override 
    {
        retu basepay + (0.5 * salesbonus); // Belongs to this class only
    }

}

static void Main()
{
    // Create new employee.
    SalesEmployee employee1 = new SalesEmployee("Alice", 1000, 500);

    decimal = employee1.CalculateExtraBonus(); // Can't see the new method
            // Derived class caot get to new method.
}

I'm thinking of trying the following. Typing out questions really helps.

{  SalesEmployee salesEmpInstance = employee1 

    decimal = salesEmpInstance.CalculateExtraBonus() 
             // Maybe this could see the method.

asked 49 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 31 تير 1395 ساعت: 10:49

صفحه بندی