CollectionExtensions.Remove<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) 方法

定义

尝试从 dictionary 中删除具有指定的 key 的值。Tries to remove the value with the specified key from the dictionary.

public:
generic <typename TKey, typename TValue>
[System::Runtime::CompilerServices::Extension]
 static bool Remove(System::Collections::Generic::IDictionary<TKey, TValue> ^ dictionary, TKey key, [Runtime::InteropServices::Out] TValue % value);
public static bool Remove<TKey,TValue> (this System.Collections.Generic.IDictionary<TKey,TValue> dictionary, TKey key, out TValue value);
static member Remove : System.Collections.Generic.IDictionary<'Key, 'Value> * 'Key * 'Value -> bool
<Extension()>
Public Function Remove(Of TKey, TValue) (dictionary As IDictionary(Of TKey, TValue), key As TKey, ByRef value As TValue) As Boolean

类型参数

TKey

dictionary 中的键的类型。The type of the keys in the dictionary.

TValue

dictionary 的值的类型。The type of the values in the dictionary.

参数

dictionary
IDictionary<TKey,TValue>

一个字典,其键类型为 TKey,其值类型为 TValueA dictionary with keys of type TKey and values of type TValue.

key
TKey

要删除的值的键。The key of the value to remove.

value
TValue

如果此方法返回 true,则为删除的值;此方法返回 false 时,则为 TValuedefault 值。When this method returns true, the removed value; when this method returns false, the default value for TValue.

返回

Boolean

如果在具有指定的 keydictionary 中找到值,则为 true;如果 dictionary 找不到与指定的 key 相关联的值,则为 falsetrue when a value is found in the dictionary with the specified key; false when the dictionary cannot find a value associated with the specified key.

例外

dictionarynulldictionary is null.

适用于