using System; using System.Collections.Generic; namespace PWAPPv2.Source.DataObjects { class NumValList { private List Pairs; public NumValList() { } public NumValList(string Content, char Delim) { string[] split = Content.Split(Delim); if ((split.Length % 2) != 0) { throw new UnevenValuesException(); } for (int i = 0; i < split.Length; i++) { this.Add(int.Parse(split[i]), split[i + 1]); i++; } } public void Add(int Num, string Val) { Pairs.Add(new NumValPair(Num, Val)); } public string GetValFromNum(int Num) { for (int i = 0; i < Pairs.Count; i++) { if (Pairs[i].Num == Num) { return Pairs[i].Value; } } throw new NotFoundException(); } public int GetNumFromVal(string Val) { for (int i = 0; i < Pairs.Count; i++) { if (Pairs[i].Value == Val) { return Pairs[i].Num; } } throw new NotFoundException(); } } class NotFoundException : Exception { } class UnevenValuesException : Exception { } }