Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Employee
- {
- public Employee(string name, int id)
- {
- this.Name = name;
- int ID = id;
- }
- public string Name { get; set; }
- public int ID { get; set; }
- }
- public class Company
- {
- private List<Employee> listWithEmployees;
- public Company()
- {
- this.listWithEmployees = new List<Employee>();
- }
- public void AddEmployee(Employee employee)
- {
- this.listWithEmployees.Add(employee);
- }
- public string this[int employeeID]
- {
- get
- {
- return listWithEmployees.FirstOrDefault(e => e.ID == employeeID).Name;
- }
- set
- {
- listWithEmployees.FirstOrDefault(e => e.ID == employeeID).Name = value;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement