using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
Hashtable hs = new Hashtable();
hs.Add(1,new Employees("郑思勉",22,"湖北武汉"));
hs.Add(2, new Employees("小榕", 30, "不知道哦"));
hs.Add(3, new Employees("冰河", 27, "不知道哦"));
//首先对剑进行排序然后再输出
ArrayList al = new ArrayList(hs.Keys);
al.Sort();
foreach (int a in al)
{
Console.WriteLine("姓名:" + (hs[a] as Employees).name);
Console.WriteLine("身份:" + (hs[a] as Employees).age);
Console.WriteLine("地址:" + (hs[a] as Employees).address);
}
}
}
//hashtable的经典用法
//首先创建一个员工类
class Employees
{
public string name;
public int age;
public string address;
public Employees(string Name,int Age,string Address)
{
this.name = Name;
this.age = Age;
this.address = Address;
}
}
}