CollectionsMarshal.GetValueRefOrAddDefault Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetValueRefOrAddDefault<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey, Boolean) |
Gets a ref to a |
GetValueRefOrAddDefault<TKey,TValue>(Dictionary<TKey,TValue>, TKey, Boolean) |
Gets a reference to a |
GetValueRefOrAddDefault<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey, Boolean)
Gets a ref to a TValue
in the Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, adding a new entry with a default value if it does not exist in the dictionary
.
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
Type Parameters
- TKey
The type of the keys in the dictionary.
- TValue
The type of the values in the dictionary.
- TAlternateKey
The type of the alternate key in the dictionary lookup.
Parameters
The dictionary to get the ref to TValue
from.
- key
- TAlternateKey
The key used for lookup.
- exists
- Boolean
Whether or not a new entry for the given key was added to the dictionary.
Returns
A reference to a TValue
in the specified Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>.
Remarks
Items should not be added to or removed from the Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey> while the ref TValue
is in use.
Applies to
GetValueRefOrAddDefault<TKey,TValue>(Dictionary<TKey,TValue>, TKey, Boolean)
- Source:
- CollectionsMarshal.cs
- Source:
- CollectionsMarshal.cs
- Source:
- CollectionsMarshal.cs
Gets a reference to a TValue
in the specified dictionary, adding a new entry with a default value if the key does not exist.
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
Type Parameters
- TKey
The type of a key.
- TValue
The type of a value.
Parameters
- dictionary
- Dictionary<TKey,TValue>
The dictionary to get the reference to TValue
from.
- key
- TKey
The key used for lookup.
- exists
- Boolean
When this method returns, contains true
if key
already existed in the dictionary, and false
if a new entry was added.
Returns
A reference to a TValue
in the specified dictionary.
Remarks
Items should not be added to or removed from the Dictionary<TKey,TValue> while the ref TValue
is in use.