0

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.

2 Answers 2

4

You're looking for composition, not inheritance:

public class Employee
{
    public List<Leave> Leaves { get; set; }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help, It had not given me complete solution but given me a trick for using Collections.
0

You can if you upper cast you type like:

Employee emp = new EmployeeDerived(); 

But for real it would be obviously still leaf type.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.