excuse me I havent dealt much with generic in c#
according to this question ,how is it possible to make a generc collection that implement two interfaces i was looking for a direct way like this:of course it makes error and totally is wrong.
interface IEmployee {void DisplayInfo();}
interface ISalary {void CalculateSalary();}
class Nurse : IEmployee, ISalary
{
//some Implementation
}
class Doctor : IEmployee, ISalary
{
//some Implementation
}
class EntryPoint
{
static void Main(string[] args)
{
System.Collections.Generic .List<T> employees where T: ISalary,IEmployee
=new System.Collections.Generic .List<T>();
}
Nurse oNurse = new Nurse();
Doctor oDoctor = new Doctor();
employees.Add(oNurse);
employees.Add(oDoctor);
}
after some Reading i found that maybe i must define a generic class like this at first:
public class HospitalEmployee<T> where T : IEmployee, ISalary
{
}
and unfortunately it dosnt work ,Now I am confused and dont know what must to do exactly,please help,thank u