I'm trying to make a wrapper class around Dictionary and I'm having trouble getting this to compile. I'm getting the error "Type parameter declaration must be an identifier not a type" when I try
with MyKey being underlined in "class MultiKeyMap<MyKey, Value>". I've tried changing MyKey to several different values, but it's always the same error. Anyone know what I'm doing wrong?Code:class MultiKeyMap<MyKey, Value> { String realKey; Dictionary<string, Value> hashMap; public MultiKeyMap() { hashMap = new Dictionary<string, Value>(); } public void Add(List<MyKey> keyList, Value val) { realKey = ""; foreach (MyKey elem in keyList) { realKey += elem.ToString(); } hashMap.Add(realKey, val); } public bool Get(List<MyKey> keyList, out Value res) { realKey = ""; foreach (MyKey elem in keyList) { realKey += elem.ToString(); } return hashMap.TryGetValue(realKey, out res); } }




Reply With Quote