次の方法で共有


CollectionsMarshal.GetValueRefOrAddDefault メソッド

定義

オーバーロード

GetValueRefOrAddDefault<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey, Boolean)
GetValueRefOrAddDefault<TKey,TValue>(Dictionary<TKey,TValue>, TKey, Boolean)

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

GetValueRefOrAddDefault<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey, Boolean)

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

型パラメーター

TKey
TValue
TAlternateKey

パラメーター

key
TAlternateKey
exists
Boolean

戻り値

TValue

適用対象

GetValueRefOrAddDefault<TKey,TValue>(Dictionary<TKey,TValue>, TKey, Boolean)

ソース:
CollectionsMarshal.cs
ソース:
CollectionsMarshal.cs
ソース:
CollectionsMarshal.cs

指定したディクショナリ内の への 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>削除したりしないでください。

適用対象