- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Collections;
- namespace CollectionDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
- Student s1 = new Student();
- Student s2 = new Student();
- Teacher t1 = new Teacher();
- Teacher t2 = new Teacher();
- s1.Name = "dwyane";
- s1.Id = 1;
- s2.Name = "lebron";
- s2.Id = 2;
- t1.Name = "paul";
- t1.Id = 3;
- t2.Name = "kobe";
- t2.Id = 4;
- /*
- ArrayList list = new ArrayList(5)
- list.Add(s1);
- list.Add(s2);
- list.Add(t1);
- list.Add(t2);
- */
- Hashtable map = new Hashtable();
- map.Add(1, s1);
- map.Add(2, s2);
- map.Add(3, t1);
- map.Add(4, t2);
- foreach (DictionaryEntry o in map)
- {
-
- Console.ReadLine();
- }
- }
- }
- }
复制代码 ===================
怎么遍历输出名字和学号? |