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>

TKey 형식의 키와 TValue 형식의 값을 사용하는 사전입니다.

key
TKey

추가할 값의 키입니다.

value
TValue

추가할 값입니다.

반환

keyvalue을(를) dictionary에 추가한 경우 true이고, dictionary에 지정된 key이(가) 이미 포함된 경우 false이며 이 경우 아무것도 추가되지 않습니다.

예외

dictionarynull입니다.

적용 대상