CollectionsMarshal.GetValueRefOrAddDefault Metoda
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Przeciążenia
GetValueRefOrAddDefault<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey, Boolean) | |
GetValueRefOrAddDefault<TKey,TValue>(Dictionary<TKey,TValue>, TKey, Boolean) |
Pobiera odwołanie do elementu |
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
Parametry typu
- TKey
- TValue
- TAlternateKey
Parametry
- key
- TAlternateKey
- exists
- Boolean
Zwraca
Dotyczy
GetValueRefOrAddDefault<TKey,TValue>(Dictionary<TKey,TValue>, TKey, Boolean)
- Źródło:
- CollectionsMarshal.cs
- Źródło:
- CollectionsMarshal.cs
- Źródło:
- CollectionsMarshal.cs
Pobiera odwołanie do elementu TValue
w określonym słowniku, dodając nowy wpis z wartością domyślną, jeśli klucz nie istnieje.
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
Parametry typu
- TKey
Typ klucza.
- TValue
Typ wartości.
Parametry
- dictionary
- Dictionary<TKey,TValue>
Słownik umożliwiający pobranie odwołania do TValue
elementu z.
- key
- TKey
Klucz używany do wyszukiwania.
- exists
- Boolean
Gdy ta metoda zwraca wartość , zawiera element , true
jeśli key
już istnieje w słowniku i false
czy został dodany nowy wpis.
Zwraca
Odwołanie do elementu TValue
w określonym słowniku.
Uwagi
Elementy nie należy dodawać ani usuwać z elementu Dictionary<TKey,TValue> , gdy odwołanie TValue
jest w użyciu.
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla