public OrderedDictionary(IOrderedDictionary <TKey, TValue> dictionary) { Initialize(); foreach (KeyValuePair <TKey, TValue> pair in dictionary) { _keyedCollection.Add(pair); } }
public TValue this[TKey key] { get { if (_keyedCollection.Contains(key) == false) { throw new ArgumentException(String.Format("The given key is not present in the dictionary: {0}", key)); } var kvp = _keyedCollection[key]; return(kvp.Value); } set { var kvp = new KeyValuePair <TKey, TValue>(key, value); var idx = IndexOf(key); if (idx > -1) { _keyedCollection[idx] = kvp; } else { _keyedCollection.Add(kvp); } } }