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 類型索引鍵和 TValue 類型值的字典。A 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

dictionary 中找到具有所指定 key 的值時,為 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.

適用於