public Employee[] GetAllEmployees() { if (com == null) { throw new Exception("The Details of the Database are not yet set"); } DataTable records = com.GetAllEmployees(); Employee[] employees = new Employee[0];//No employees yet.... foreach (DataRow row in records.Rows) { Employee emp = new Employee(); emp.EmpID = int.Parse(row[0].ToString()); emp.EmpName = row[1].ToString(); emp.EmpAddress = row[2].ToString(); emp.EmpSalary = Convert.ToInt32(row[3]); Array backUp = employees.Clone() as Employee[]; employees = new Employee[backUp.Length + 1]; //copy one by one all the elements of backup to this new Array... if (backUp.Length != 0) { backUp.CopyTo(employees, 0); } employees[employees.Length - 1] = emp; } return(employees); }