locked
No suitable method found to override RRS feed

  • Question

  • I can't find the issue :(

    public Benefit()
            {
                
            }

            public Benefit(string health, double life, int vaca)
            {
                healthinsurance = health;
                lifeinsurance = life;
                vacation = vaca;
            }

            public override string DisplayBenefit()  // this is where its giving me no method found to override
            {
                return "Health Insurance: " + healthinsurance + "Life Insurance: " + lifeinsurance + "Vacation: " + vacation;
            }


    • Edited by Bri007 Tuesday, October 2, 2012 7:33 PM
    Tuesday, October 2, 2012 7:32 PM

Answers

  • Take out the word "override".  Just write:

    public string DisplayBenefit() 
    {
       return //...
    

    You only use override if you're overriding a virtual method defined in the base class.  In your case, the base class doesn't have a method defined as public virtual string DisplayBenefit() or public abstract string DisplayBenefit();


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Proposed as answer by Norkk Tuesday, October 2, 2012 7:46 PM
    • Marked as answer by Jason Dot WangModerator Wednesday, October 10, 2012 9:11 AM
    Tuesday, October 2, 2012 7:43 PM
    Moderator