CollectionsMarshal.GetValueRefOrNullRef Method

Definition

Overloads

GetValueRefOrNullRef<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey)

Gets either a ref to a TValue in the Dictionary<TKey,TValue> or a ref null if it does not exist in the dictionary.

GetValueRefOrNullRef<TKey,TValue>(Dictionary<TKey,TValue>, TKey)

Gets either a reference to a TValue in the Dictionary<TKey,TValue> or a reference null if it does not exist in the dictionary.

GetValueRefOrNullRef<TKey,TValue,TAlternateKey>(Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>, TAlternateKey)

Gets either a ref to a TValue in the Dictionary<TKey,TValue> or a ref null if it does not exist in the dictionary.

public:
generic <typename TKey, typename TValue, typename TAlternateKey>
 static TValue % GetValueRefOrNullRef(System::Collections::Generic::Dictionary<TKey, TValue>::AlternateLookup<TAlternateKey> dictionary, TAlternateKey key);
public static ref TValue GetValueRefOrNullRef<TKey,TValue,TAlternateKey> (System.Collections.Generic.Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey> dictionary, TAlternateKey key);
static member GetValueRefOrNullRef : System.Collections.Generic.Dictionary<'Key, 'Value>.AlternateLookup<'AlternateKey> * 'AlternateKey -> 'Value
Public Shared Function GetValueRefOrNullRef(Of TKey, TValue, TAlternateKey) (dictionary As Dictionary(Of TKey, TValue).AlternateLookup(Of TAlternateKey), key As TAlternateKey) 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 an alternate key for lookups in the dictionary.

Parameters

dictionary
Dictionary<TKey,TValue>.AlternateLookup<TAlternateKey>

The dictionary to get the ref to TValue from.

key
TAlternateKey

The key used for lookup.

Returns

TValue

A reference to a TValue in the Dictionary<TKey,TValue> or a reference null if it does not exist in the dictionary..

Remarks

Items should not be added or removed from the Dictionary<TKey,TValue> while the ref TValue is in use.

The ref null can be detected by calling IsNullRef<T>(T).

Applies to

GetValueRefOrNullRef<TKey,TValue>(Dictionary<TKey,TValue>, TKey)

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

Gets either a reference to a TValue in the Dictionary<TKey,TValue> or a reference null if it does not exist in the dictionary.

public:
generic <typename TKey, typename TValue>
 static TValue % GetValueRefOrNullRef(System::Collections::Generic::Dictionary<TKey, TValue> ^ dictionary, TKey key);
public static ref TValue GetValueRefOrNullRef<TKey,TValue> (System.Collections.Generic.Dictionary<TKey,TValue> dictionary, TKey key);
static member GetValueRefOrNullRef : System.Collections.Generic.Dictionary<'Key, 'Value> * 'Key -> 'Value
Public Shared Function GetValueRefOrNullRef(Of TKey, TValue) (dictionary As Dictionary(Of TKey, TValue), key As TKey) 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 ref to TValue from.

key
TKey

The key used for lookup.

Returns

TValue

A reference to a TValue in the Dictionary<TKey,TValue> or a reference null if it does not exist in the dictionary..

Remarks

Items should not be added or removed from the Dictionary<TKey,TValue> while the ref TValue is in use.

The ref null can be detected by calling System.Runtime.CompilerServices.Unsafe.IsNullRef<T>(T).

Applies to