CollectionExtensions.TryAdd<TKey,TValue> 메서드

정의

지정된 keyvalue 및 에 추가하려고 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

형식 매개 변수

TKey

사전에 있는 키의 형식입니다.

TValue

사전에 있는 값의 형식입니다.

매개 변수

dictionary
IDictionary<TKey,TValue>

형식의 키와 형식 TKeyTValue의 값이 있는 사전입니다.

key
TKey

추가할 값의 키입니다.

value
TValue

추가할 값입니다.

반품

true지정된 항목이 keyvalue 이미 포함되어 key있는 경우 dictionary ; false 에 성공적으로 추가dictionary되면 아무 것도 추가되지 않습니다.

예외

dictionarynull입니다.

적용 대상