Enhanced C#
Language of your choice: library documentation
Static Public Member Functions | List of all members
Loyc.Collections.TryGetExt Class Reference

Standard extension methods for ITryGet<K, V>. More...


Source file:

Remarks

Standard extension methods for ITryGet<K, V>.

Static Public Member Functions

static Maybe< V > TryGet< K, V > (this ITryGet< K, V > self, K key)
 Returns the value at the specified key or index, wrapped in Maybe<V>. More...
 
static V TryGet< K, V > (this ITryGet< K, V > self, K key, V defaultValue)
 Returns the value at the specified key or index, or the specified default value if the key was not found. More...
 

Member Function Documentation

◆ TryGet< K, V >() [1/2]

static Maybe<V> Loyc.Collections.TryGetExt.TryGet< K, V > ( this ITryGet< K, V >  self,
key 
)
inlinestatic

Returns the value at the specified key or index, wrapped in Maybe<V>.

Parameters
keyA lookup key that might be associated with a value in this object. If K is an integer, this value could be an index into a list.
Returns
A value associated with the key, wrapped in Maybe<V> so that Maybe<V>.HasValue is false if lookup fails.

◆ TryGet< K, V >() [2/2]

static V Loyc.Collections.TryGetExt.TryGet< K, V > ( this ITryGet< K, V >  self,
key,
defaultValue 
)
inlinestatic

Returns the value at the specified key or index, or the specified default value if the key was not found.

Parameters
keyA lookup key that might be associated with a value in this object. If K is an integer, this value could be an index into a list.
defaultValueA value to return if lookup fails.