// 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.IO; using System.Collections; public class SuperCollection { private Hashtable map = new Hashtable(); public void Load(string filename) { StreamReader sr = new StreamReader(filename); string line; while((line = sr.ReadLine()) != null) { string[] parts = line.Split(";".ToCharArray()); string key = parts[0]+ "#" + parts[1]; ArrayList lst = (ArrayList)map[key]; if(lst == null) { lst = new ArrayList(); map.Add(key, lst); } lst.Add(parts[3]); } sr.Close(); } public int Count(string key) { ArrayList lst = (ArrayList)map[key]; if(lst == null) { return 0; } else { return lst.Count; } } public string Item(string key, int n) { ArrayList lst = (ArrayList)map[key]; if(lst == null) { return null; } else { return (String)lst[n]; } } } class MainClass { public static void Main(string[] args) { SuperCollection sc = new SuperCollection(); sc.Load(@"C:\fil2.dat"); for(int i = 0; i < sc.Count(70 + "#" + 4601058); i++) { Console.WriteLine(sc.Item(70 + "#" + 4601058, i)); } } }