CollectionExtensions.TryAdd<TKey,TValue> メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したkeyの追加を試み、valueに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
追加する値。
返品
true
keyとvalueがdictionaryに正常に追加された場合はfalse。dictionaryに指定されたkeyが既に含まれている場合に。その場合は何も追加されません。
例外
dictionary は nullです。