CollectionExtensions.TryAdd<TKey,TValue>(IDictionary<TKey,TValue>, TKey, TValue) Method

Definition

지정된 keyvalue을(를) dictionary에 추가하려고 시도합니다.Tries to add the specified key and value to the dictionary.

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

Type Parameters

TKey

사전의 키 형식입니다.The type of the keys in the dictionary.

TValue

사전의 값 형식입니다.The type of the values in the dictionary.

Parameters

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 add.

value
TValue

추가할 값입니다.The value to add.

Returns

Boolean

keyvalue을(를) dictionary에 추가한 경우 true이고, dictionary에 지정된 key이(가) 이미 포함된 경우 false이며 이 경우 아무것도 추가되지 않습니다.true when the key and value are successfully added to the dictionary; false when the dictionary already contains the specified key, in which case nothing gets added.

Exceptions

dictionarynull입니다.dictionary is null.

Applies to