CollectionsMarshal.GetValueRefOrAddDefault<TKey,TValue> メソッド

定義

指定したディクショナリ内の への TValue 参照を取得し、キーが存在しない場合は既定値で新しいエントリを追加します。

public:
generic <typename TKey, typename TValue>
 static TValue % GetValueRefOrAddDefault(System::Collections::Generic::Dictionary<TKey, TValue> ^ dictionary, TKey key, [Runtime::InteropServices::Out] bool % exists);
public static ref TValue? GetValueRefOrAddDefault<TKey,TValue> (System.Collections.Generic.Dictionary<TKey,TValue> dictionary, TKey key, out bool exists);
static member GetValueRefOrAddDefault : System.Collections.Generic.Dictionary<'Key, 'Value> * 'Key * bool -> 'Value
Public Shared Function GetValueRefOrAddDefault(Of TKey, TValue) (dictionary As Dictionary(Of TKey, TValue), key As TKey, ByRef exists As Boolean) As TValue

型パラメーター

TKey

キーの型。

TValue

値の型。

パラメーター

dictionary
Dictionary<TKey,TValue>

参照 TValue の取得元のディクショナリ。

key
TKey

検索に使用されるキー。

exists
Boolean

このメソッドが戻るときに、 はディクショナリに既に存在する場合keyは を格納しfalse、新しいエントリが追加された場合は を格納trueします。

戻り値

TValue

指定したディクショナリ内の への参照 TValue

注釈

ref TValue が使用されている間、項目を に追加したり、 からDictionary<TKey,TValue>削除したりしないでください。

適用対象