这是我的代码(应该很容易理解我想要实现的目标):
public class Order
{
private Drink drink;
public Drink Drink {get { return drink; } set { drink = value; }}
}
public class Drink
{
enum colour
{
Red, Transparent
};
}
public class cocktail : Drink
{
private int alcoholContent;
public int AlcoholContent { get { return alcoholContent; } set { alcoholContent = value; } }
}
然后我试图访问这些属性,但它们不存在:
Order order = new Order();
order.Drink = new cocktail();
order.Drink. <- no alcohol content?
这是为什么?我以为我确实创建了一个鸡尾酒课,而不仅仅是一个饮料?我究竟做错了什么?
谢谢!