Dictionary<TKey,TValue>.KeyCollection.ICollection<TKey>.Remove(TKey) 方法

定义

ICollection<T> 中移除特定对象的第一个匹配项。Removes the first occurrence of a specific object from the ICollection<T>. 此实现始终引发 NotSupportedExceptionThis implementation always throws NotSupportedException.

 virtual bool System.Collections.Generic.ICollection<TKey>.Remove(TKey item) = System::Collections::Generic::ICollection<TKey>::Remove;
bool ICollection<TKey>.Remove (TKey item);
abstract member System.Collections.Generic.ICollection<TKey>.Remove : 'Key -> bool
override this.System.Collections.Generic.ICollection<TKey>.Remove : 'Key -> bool
Function Remove (item As TKey) As Boolean Implements ICollection(Of TKey).Remove

参数

item
TKey

要从 ICollection<T> 中删除的对象。The object to remove from the ICollection<T>.

返回

Boolean

如果从 true 中成功移除 item,则为 ICollection<T>;否则为 falsetrue if item was successfully removed from the ICollection<T>; otherwise, false. 如果在原始 ICollection<T> 中没有找到项,此方法也会返回 falseThis method also returns false if item was not found in the original ICollection<T>.

实现

例外

始终引发。Always thrown.

注解

在如何确定对象是否相等方面这些实现可能存在差异;例如,List<T> 使用 Default,而 Dictionary<TKey,TValue> 允许用户指定 IComparer<T> 实现以用来对键进行比较。Implementations can vary in how they determine equality of objects; for example, List<T> uses Default, whereas, Dictionary<TKey,TValue> allows the user to specify the IComparer<T> implementation to use for comparing keys.

适用于

另请参阅