Esempio n. 1
0
        static void Main(string[] args)
        {
            Mahasiswa mhs1 = new Mahasiswa();

            mhs1.Nim           = "1234";
            mhs1.NamaMahasiswa = "Erick";

            Mahasiswa mhs2 = new Mahasiswa();

            mhs1.Nim           = "1235";
            mhs1.NamaMahasiswa = "Wely";

            Dosen dosen1 = new Dosen();

            mhs1.Nik       = "0043";
            mhs1.NamaDosen = "Jhono";

            Dosen dosen2 = new Dosen();

            mhs1.Nik       = "0045";
            mhs1.NamaDosen = "Jhoni";

            ArrayList list = new ArrayList();

            list.Add(mhs1);
            list.Add(mhs2);
            list.Add(dosen1);
            list.Add(dosen2);

            Mahasiswa mhs = (Mahasiswa)list[1];

            Console.WriteLine("{0}, {1}", mhs.Nim, mhs.NamaMahasiswa);

            Dosen dosen = (Dosen)list[2];

            Console.WriteLine("{0}, {1}", dosen.Nik, dosen.NamaDosen);

            Console.ReadKey();
        }