// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections; class MainClass { public static void Main(string[] args) { Customer c1 = new Customer(1, "Kunde 1"); Console.WriteLine(c1.No + " " + c1.Name); Console.WriteLine(c1); CustomerList clist = new CustomerList(); clist.Add(c1); Customer c2 = new Customer(2, "Kunde 2"); clist.Add(c2); Console.WriteLine(clist.Get(2)); Console.WriteLine(clist[2]); } } class CustomerList { private Hashtable list; public CustomerList() { list = new Hashtable(); } public void Add(Customer c) { list.Add(c.No, c); } public Customer Get(int no) { return (Customer)list[no]; } public Customer this[int no] { get { return (Customer)list[no]; } } } class Customer { private int no; private string name; public Customer(int no, string name) { this.no = no; this.name = name; } public int No { get { return no; } } public string Name { get { return name; } } public override string ToString() { return (no + " " + name); } }