public static class Exercise
{
static int Main(string[] args)
{
var StaffMembers = new Employee[3];
StaffMembers[0] = new Employee();
StaffMembers[0].EmployeeNumber = 20204;
StaffMembers[0].EmployeeName = "Harry Fields";
StaffMembers[0].Status = EmploymentStatus.FullTime;
StaffMembers[0].HourlySalary = 16.85;
StaffMembers[1] = new Employee();
StaffMembers[1].EmployeeNumber = 92857;
StaffMembers[1].EmployeeName = "Jennifer Almonds";
StaffMembers[1].Status = EmploymentStatus.FullTime;
StaffMembers[1].HourlySalary = 22.25;
StaffMembers[2] = new Employee();
StaffMembers[2].EmployeeNumber = 42963;
StaffMembers[2].EmployeeName = "Sharon Culbritt";
StaffMembers[2].Status = EmploymentStatus.PartTime;
StaffMembers[2].HourlySalary = 10.95;
return 0;
}
}
T[] InitializeArray<T>(int length) where T : new() {
T[] array = new T[length];
for (int i = 0; i < length; ++i) {
array[i] = new T();
}
return array;
}
// Usage:
MyObjects[] my_objects = InitializeArray<MyObjects>(10);
// we will call 'Person' an object
Person[] personArr = new Person[10];
Person[,] person2DArr = new Person[10,10];