Dictionary<string,Employee> Employees =new Dictionary<string,Employee>();
Employee emp1 = new Employee("Emp01","Employee1");
Employee emp2 = new Employee("Emp02","Employee2");
Employee emp3 = new Employee("Emp03","Employee3");
Employee emp4 = new Employee("Emp04","Employee4");
Employee emp5 = new Employee("Emp05","Employee5");
Employees.Add(emp1.empID, emp1);
Employees.Add(emp2.empID, emp2);
Employees.Add(emp3.empID, emp3);
Employees.Add(emp4.empID, emp4);
Employees.Add(emp5.empID, emp5);
Console.WriteLine(Employees["Emp05"].getNameAndID());
foreach (KeyValuePair<string,Employee> emp in Employees)
{
Console.WriteLine(emp.Key +" >>>>> " + emp.Value.empName);
Console.WriteLine(emp.Value.ToString());
}
public class Employee
{
public string empID;
public readonly string empName;
public Employee(string empID, string name)
{
this.empID = empID;
this.empName = name;
}
}