Partager via


CollectionsMarshal.GetValueRefOrAddDefault Méthode

Définition

Surcharges

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

Obtient une référence à un TValue dans le dictionnaire spécifié, en ajoutant une nouvelle entrée avec une valeur par défaut si la clé n’existe pas.

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

Paramètres de type

TKey
TValue
TAlternateKey

Paramètres

key
TAlternateKey
exists
Boolean

Retours

TValue

S’applique à

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

Source:
CollectionsMarshal.cs
Source:
CollectionsMarshal.cs
Source:
CollectionsMarshal.cs

Obtient une référence à un TValue dans le dictionnaire spécifié, en ajoutant une nouvelle entrée avec une valeur par défaut si la clé n’existe pas.

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

Paramètres de type

TKey

Type d’une clé.

TValue

Type d’une valeur.

Paramètres

dictionary
Dictionary<TKey,TValue>

Dictionnaire à partir duquel obtenir la référence TValue .

key
TKey

Clé utilisée pour la recherche.

exists
Boolean

Lorsque cette méthode est retournée, contient true si key existait déjà dans le dictionnaire et false si une nouvelle entrée a été ajoutée.

Retours

TValue

Référence à un TValue dans le dictionnaire spécifié.

Remarques

Les éléments ne doivent pas être ajoutés ou supprimés du Dictionary<TKey,TValue> pendant que la référence TValue est en cours d’utilisation.

S’applique à