public bool TryGetValue(
TKey key,
out TValue value
)
Public Function TryGetValue (
key As TKey,
<OutAttribute> ByRef value As TValue
) As Boolean
public:
virtual bool TryGetValue(
TKey key,
[OutAttribute] TValue% value
) sealed
abstract TryGetValue :
key : 'TKey *
value : 'TValue byref -> bool
override TryGetValue :
key : 'TKey *
value : 'TValue byref -> bool
Use this method if the CacheTKey, TValue was initialized without an item loader, or when you want to determine if a key exists in the CacheTKey, TValue and if so, you want to get the value as well. Reading the indexer property would transparently load a non-existing element by calling the item loader delegate that was passed to the constructor.
Works exactly the same way as in case of DictionaryTKey, TValue class. If key is not found, does not use the item loader passed to the constructor.
If the key is not found, then the value parameter gets the appropriate default value for the type TValue; for example, 0 (zero) for integer types, for Boolean types, and for reference types.
This method approaches an O(1) operation.
ArgumentNullException | key is . |