public void Update(TKey key, TValue value) { KeyAndValue <TKey, TValue> keyAndValue = new KeyAndValue <TKey, TValue>(key, value); if (!GetTable().ContainsKey(key)) { // TODO: fix it // InvalidCastException: Specified cast is not valid. list.Add(ConvertValueWithKeyToKeyAndValue(key, value)); } else { Dictionary <TKey, TValue> _table = new Dictionary <TKey, TValue>(GetTable()); _table[key] = value; list = ConvertDictionaryToList(_table); } }
/// <summary> /// コンストラクタ /// </summary> /// <param name="pair">登録するペア</param> public KeyAndValue(KeyAndValue <TKey, TValue> pair) { key = pair.key; value = pair.value; }