P
phoenix
I have three classes: top, middle, and bottom. The middle class inherits
the Name property of its parent, top. The bottom class inherits the Name
and ID properties of its parent, middle.
However, if I create an instance of type bottom in a different class, I am
only able to access its sole property -- Date. I don't have access to the
Name and ID properties. What am I doing wrong? I can access these
properties within the bottom code.
public class top {
private string name;
public string Name {
get { return name; }
set { name = value; }
}
}
public class middle : top {
private int id;
public int ID {
get { return id; }
set { id = value; }
}
}
public class bottom: middle {
private DateTime date;
public DateTime Date {
get { return date; }
set { date = value; }
}
}
public class stuff
{
private void DoStuff()
{
bottom bot = new bottom();
string name = bot.Name; // compile error
int id = bot.ID; // compile error
DateTime date = bot.Date; // ok
}
}
the Name property of its parent, top. The bottom class inherits the Name
and ID properties of its parent, middle.
However, if I create an instance of type bottom in a different class, I am
only able to access its sole property -- Date. I don't have access to the
Name and ID properties. What am I doing wrong? I can access these
properties within the bottom code.
public class top {
private string name;
public string Name {
get { return name; }
set { name = value; }
}
}
public class middle : top {
private int id;
public int ID {
get { return id; }
set { id = value; }
}
}
public class bottom: middle {
private DateTime date;
public DateTime Date {
get { return date; }
set { date = value; }
}
}
public class stuff
{
private void DoStuff()
{
bottom bot = new bottom();
string name = bot.Name; // compile error
int id = bot.ID; // compile error
DateTime date = bot.Date; // ok
}
}