Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
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 Maybe< T > TryGet< T > (this ITryGet< int, T > self, int key)
 
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...
 
static Maybe< T > TryGet< T > (this INegListSource< T > self, int key)
 
static Maybe< T > TryGet< T > (this IListSource< T > self, int key)
 
static Maybe< T > TryGet< T > (this IArray< T > self, int key)
 
static Maybe< ILNodeTryGet (this ILNode self, int key)
 
static T TryGet< T > (this INegListSource< T > self, int key, T defaultValue)
 
static T TryGet< T > (this IListSource< T > self, int key, T defaultValue)
 
static T TryGet< T > (this IArray< T > self, int key, T defaultValue)
 
static ILNode TryGet (this ILNode self, int key, ILNode defaultValue)
 

Member Function Documentation

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.
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.

There's no attribute like [return: MaybeNullIfNull("defaultValue")], so instead defaultValue is NOT marked with [AllowNull]. If you want to use defaultValue == null, use the other overload: x.TryGet(key).Or(null).