Assume everybody in the company is an Employee:
public interface IEmployeeInfo
{
string Name {set; get;}
string Address {set; get;}
decimal Salary { set; get; }
}
public interface IEmployee : IEmployeeInfo
{
string Title{set; get;}
IManager EManager { set; get; }
}
public interface IManager : IEmployee
{
List<IEmployee> EmployeesManaged {set; }
void AddManagedEmployee(IEmployee employee);
void RemoveManagedEmployee(IEmployee employee);
bool IsManagedBy(IEmployee employee);
}
Then 'Employee would inherit from IEmployee, and 'Manager would inherit from IManager.
Note the 'set only property 'EmployeesManaged in 'IManager: assuming you want to encapsulate the usage of that List, you can use an explicit interface implementation in the Manager class:
private List<IEmployee> EmployeesManaged { get; set; }
List<IEmployee> IManager.EmployeesManaged
{
set => this.EmployeesManaged = value;
}
Then, only internal methods of 'Manager can access the List:
public void AddManagedEmployee(IEmployee employee)
{
if (IsManagedBy(employee))
{
}
else
{
EmployeesManaged.Add(employee);
employee.EManager = this;
}
}