Vinod
Vinod

Reputation: 1

how to use inheritance for inheriting properties form multiple classes?

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

Answers (2)

Tigran
Tigran

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

CodeCaster
CodeCaster

Reputation: 151594

You're looking for composition, not inheritance:

public class Employee
{
    public List<Leave> Leaves { get; set; }
}

Upvotes: 4

Related Questions