Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好吧,我的课很少(Employee、Leaves、Shift、Weekly_off)。我想通过使用员工类对象来访问员工的叶子。叶子和其他人也是如此。所以请帮我解决这个问题。
您正在寻找组合,而不是继承:
public class Employee { public List<Leave> Leaves { get; set; } }
你可以,如果你上投你输入像:
Employee emp = new EmployeeDerived();
但实际上它显然仍然是叶子类型。