/// <summary> /// Removes the name-value pair with the specified key from the collection. /// </summary> /// <param name="name">The name associated with a value in a name-value pair.</param> /// <returns><c>true</c> if item successfully removed; <c>false</c> otherwise.</returns> public bool Remove([NotNull] string name) { var i = -1; NameValuePair nvp = null; try { if (v2Coll == null) { i = unboundDict.FindIndex(p => p.Name == name); if (i != -1) { nvp = unboundDict[i]; unboundDict.RemoveAt(i); } return(i != -1); } for (i = 0; i < v2Coll.Count; i++) { if (name == v2Coll[i].Name) { nvp = new NameValuePair(v2Coll[i]).Clone(); v2Coll.Remove(i); return(true); } } i = -1; } finally { if (i != -1) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Item[]")); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, nvp, i)); } } return(false); }
/// <summary> /// Removes a selected name-value pair from the collection. /// </summary> /// <param name="index"> Index of the pair to remove. </param> public void RemoveAt(int index) { v2Coll.Remove(index); }