Reputation: 1
well, I have few classes (Employee, Leaves,Shift,Weekly_off). I want to Access the leaves of employee by using Employee Class object. same for Leaves and others. So please help me with this issue.
Upvotes: 0
Views: 40
Reputation: 62246
You can if you upper cast you type like:
Employee emp = new EmployeeDerived();
But for real it would be obviously still leaf type.
Upvotes: 0
Reputation: 151594
You're looking for composition, not inheritance:
public class Employee
{
public List<Leave> Leaves { get; set; }
}
Upvotes: 4