0

I'm currently struggling with the development of a todo list (mostly unimportant) within which I am creating a base class "Task", which has the classes "Note", "extendedTask" and "Reminder". I also have a class called "Appointment" that inherits from reminder.

All of these classes implement an interface with a method called "detailsShow" I want the method to be called from the child classes and then call the same method from the parent class.

The method in the base class is defined as such

public virtual string detailsShow()
    {
        return "Description: " + _taskDescription;
    }

While the child class defines it in this way (Note is used in this example as it has the least number of variables)

public override string detailsShow()
    {
        return "Details: " + _noteDescription;
    }

I suspect it is how i have defined both the method in the base class and the method in the child classes.

On another note, how do i begin a new line in a RichText box

(How i want it to look)

Stuffhere
Andstuffhere

(what i get using my method)

Stuffhere \nAndstuffhere

many thanks in advance

WillzSawyer
  • 133
  • 1
  • 4
  • 12

2 Answers2

3

Given the current structure of your code, your inheritor can call it's parent, as in:

public override string detailsShow()
{
    return base.detailsShow() + " Details: " + _noteDescription;
}

which could yield something like:

Description: Stuffhere Details: Andstuffhere

You cannot have a reference to the base class Task and force it to execute the virtual detailsShow as the inheritor gets to make that decision.

Ed Chapel
  • 6,842
  • 3
  • 30
  • 44
1

You can call the detailsShow method of the base class and include Environment.NewLine to begin a new line in the RichTextBox:

public override string detailsShow()
{
    return base.detailsShow() + Environment.NewLine + 
        "Details: " + _noteDescription;
}
markyd13
  • 709
  • 6
  • 15