/*
Learning C#
by Jesse Liberty
Publisher: O'Reilly
ISBN: 0596003765
*/
using System;
namespace ArrayDemo
{
// a simple class to store in the array
class Employee
{
privateint empID;
// constructor
public Employee(int empID)
{
this.empID = empID;
}
public override string ToString()
{
return empID.ToString();
}
}
publicclass TesterClassArray
{
publicvoid Run()
{
int[] intArray;
Employee[] empArray;
intArray = newint[5];
empArray = new Employee[3];
// populate the array
for (int i = 0;i<empArray.Length;i++)
{
empArray[i] = new Employee(i+5);
}
Console.WriteLine("The int array...");
for (int i = 0;i<intArray.Length;i++)
{
Console.WriteLine(intArray[i].ToString());
}
Console.WriteLine("\nThe employee array...");
for (int i = 0;i<empArray.Length;i++)
{
Console.WriteLine(empArray[i].ToString());
}
}
[STAThread]
staticvoid Main()
{
TesterClassArray t = new TesterClassArray();
t.Run();
}
}
}