Class LinqToOpt
LINQ facilities for options.
Inherited Members
Namespace: Hgk.Zero.Options.Linq
Assembly: Hgk.Zero.Options.dll
Syntax
public static class LinqToOpt
Remarks
This class contains a large number of LINQ-compatible methods. While all options are also enumerables, and can therefore be used with methods provided by Enumerable, most of the operators are specialized here for options in order to optimize the algorithms for use with zero- or one-element collections (such as Distinct<TSource>(IOpt<TSource>)), and also to return options from operations guaranteed to return at most one element when performed on an option (such as Zip<TFirst, TSecond, TResult>(IOpt<TFirst>, IEnumerable<TSecond>, Func<TFirst, TSecond, TResult>)). In general, the result of applying any LINQ operation in this class to an option is defined to be sequence-equal to the result of applying the same operation from Enumerable to the same option.
Similarly to the methods in Enumerable, most option-returning methods in this class are implemented using deferred execution; that is, the query represented by the method is not actually executed until the contents of the result are resolved directly, for example, by enumeration, using foreach, or calling a method such as ToFixed<TSource>(IOpt<TSource>) or Match<TSource, TResult>(IOpt<TSource>, Func<TResult>, Func<TSource, TResult>).
Some methods instead use or return Opt<T>, which is a type for fixed, immutable options. The contents of these are immediate and not deferred.
Methods
| Improve this Doc View SourceAggregate<TSource>(IOpt<TSource>, Func<TSource, TSource, TSource>)
Applies an accumulator function over the elements of an option.
Declaration
public static TSource Aggregate<TSource>(this IOpt<TSource> source, Func<TSource, TSource, TSource> func)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TSource, TSource> | func | An accumulator function to be applied to an element of |
Returns
Type | Description |
---|---|
TSource | The final accumulator value, which is the single element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
Since an option can only ever have zero elements or one element, func
is never called (but must still be supplied).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Aggregate<TSource, TAccumulate>(IOpt<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>)
Applies an accumulator function over the elements of an option, using the specified seed value.
Declaration
public static TAccumulate Aggregate<TSource, TAccumulate>(this IOpt<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
TAccumulate | seed | The initial value for the accumulator. |
Func<TAccumulate, TSource, TAccumulate> | func | An accumulator function to be applied to the accumulator and an element of |
Returns
Type | Description |
---|---|
TAccumulate | The final accumulator value, which is either |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TAccumulate | The type of the accumulator value. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Aggregate<TSource, TAccumulate, TResult>(IOpt<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>, Func<TAccumulate, TResult>)
Applies an accumulator function over the elements of an option, using the specified seed value, and transforming the final result with the specified result selector.
Declaration
public static TResult Aggregate<TSource, TAccumulate, TResult>(this IOpt<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func, Func<TAccumulate, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
TAccumulate | seed | The initial value for the accumulator. |
Func<TAccumulate, TSource, TAccumulate> | func | An accumulator function to be applied to the accumulator and an element of |
Func<TAccumulate, TResult> | resultSelector | A function to transform the accumulator value into the result. |
Returns
Type | Description |
---|---|
TResult | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TAccumulate | The type of the accumulator value. |
TResult | The type of the result. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
All<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns whether all elements of an option satisfy a predicate.
Declaration
public static bool All<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
Boolean | true, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Any<TSource>(IOpt<TSource>)
Returns whether an option contains any elements.
Declaration
public static bool Any<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
Boolean | true if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Any<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns whether any element of an option satisfies a predicate.
Declaration
public static bool Any<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
Boolean | true, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
AsIOpt<TSource>(IOpt<TSource>)
Returns this option typed as IOpt<T>.
Declaration
public static IOpt<TSource> AsIOpt<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to type as IOpt<T>. |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The element type of |
Average(IOpt<Decimal>)
Computes the average of the contents of an option.
Declaration
public static decimal Average(this IOpt<decimal> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Decimal> | source | A source option. |
Returns
Type | Description |
---|---|
Decimal | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average(IOpt<Double>)
Computes the average of the contents of an option.
Declaration
public static double Average(this IOpt<double> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Double> | source | A source option. |
Returns
Type | Description |
---|---|
Double | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average(IOpt<Int32>)
Computes the average of the contents of an option.
Declaration
public static double Average(this IOpt<int> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Int32> | source | A source option. |
Returns
Type | Description |
---|---|
Double | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average(IOpt<Int64>)
Computes the average of the contents of an option.
Declaration
public static double Average(this IOpt<long> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Int64> | source | A source option. |
Returns
Type | Description |
---|---|
Double | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average(IOpt<Nullable<Decimal>>)
Computes the average of the non-null contents of an option.
Declaration
public static decimal? Average(this IOpt<decimal? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Decimal>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Average(IOpt<Nullable<Double>>)
Computes the average of the non-null contents of an option.
Declaration
public static double? Average(this IOpt<double? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Double>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Double> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Average(IOpt<Nullable<Int32>>)
Computes the average of the non-null contents of an option.
Declaration
public static double? Average(this IOpt<int? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Int32>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Double> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Average(IOpt<Nullable<Int64>>)
Computes the average of the non-null contents of an option.
Declaration
public static double? Average(this IOpt<long? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Int64>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Double> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Average(IOpt<Nullable<Single>>)
Computes the average of the non-null contents of an option.
Declaration
public static float? Average(this IOpt<float? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Single>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Single> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Average(IOpt<Single>)
Computes the average of the contents of an option.
Declaration
public static float Average(this IOpt<float> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Single> | source | A source option. |
Returns
Type | Description |
---|---|
Single | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average<TSource>(IOpt<TSource>, Func<TSource, Decimal>)
Computes the average of a projection of the contents of an option.
Declaration
public static decimal Average<TSource>(this IOpt<TSource> source, Func<TSource, decimal> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Decimal> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Decimal | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average<TSource>(IOpt<TSource>, Func<TSource, Double>)
Computes the average of a projection of the contents of an option.
Declaration
public static double Average<TSource>(this IOpt<TSource> source, Func<TSource, double> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Double> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Double | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average<TSource>(IOpt<TSource>, Func<TSource, Int32>)
Computes the average of a projection of the contents of an option.
Declaration
public static double Average<TSource>(this IOpt<TSource> source, Func<TSource, int> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Double | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average<TSource>(IOpt<TSource>, Func<TSource, Int64>)
Computes the average of a projection of the contents of an option.
Declaration
public static double Average<TSource>(this IOpt<TSource> source, Func<TSource, long> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int64> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Double | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Average<TSource>(IOpt<TSource>, Func<TSource, Nullable<Decimal>>)
Computes the average of the non-null elements of a projection of the contents of an option.
Declaration
public static decimal? Average<TSource>(this IOpt<TSource> source, Func<TSource, decimal? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Decimal>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Average<TSource>(IOpt<TSource>, Func<TSource, Nullable<Double>>)
Computes the average of the non-null elements of a projection of the contents of an option.
Declaration
public static double? Average<TSource>(this IOpt<TSource> source, Func<TSource, double? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Double>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Double> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Average<TSource>(IOpt<TSource>, Func<TSource, Nullable<Int32>>)
Computes the average of the non-null elements of a projection of the contents of an option.
Declaration
public static double? Average<TSource>(this IOpt<TSource> source, Func<TSource, int? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Int32>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Double> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Average<TSource>(IOpt<TSource>, Func<TSource, Nullable<Int64>>)
Computes the average of the non-null elements of a projection of the contents of an option.
Declaration
public static double? Average<TSource>(this IOpt<TSource> source, Func<TSource, long? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Int64>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Double> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Average<TSource>(IOpt<TSource>, Func<TSource, Nullable<Single>>)
Computes the average of the non-null elements of a projection of the contents of an option.
Declaration
public static float? Average<TSource>(this IOpt<TSource> source, Func<TSource, float? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Single>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Single> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Average<TSource>(IOpt<TSource>, Func<TSource, Single>)
Computes the average of a projection of the contents of an option.
Declaration
public static float Average<TSource>(this IOpt<TSource> source, Func<TSource, float> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Single> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Single | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Cast<TResult>(IOpt)
Casts the elements of an option to the specified type.
Declaration
public static IOpt<TResult> Cast<TResult>(this IOpt source)
Parameters
Type | Name | Description |
---|---|---|
IOpt | source | A source option. |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option having the same contents as |
Type Parameters
Name | Description |
---|---|
TResult | The type to which to cast the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
If source
is already an IOpt<T> with TResult
as its element type, it is returned unchanged.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidCastException |
|
Contains<TSource>(IOpt<TSource>, TSource)
Determines whether an option contains an element that equals the specified value.
Declaration
public static bool Contains<TSource>(this IOpt<TSource> source, TSource value)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
TSource | value | A value to find in |
Returns
Type | Description |
---|---|
Boolean | true, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
The comparison, if any, is performed using Default for
TSource
.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Contains<TSource>(IOpt<TSource>, TSource, IEqualityComparer<TSource>)
Determines whether an option contains an element that equals the specified value, according to the specified comparer.
Declaration
public static bool Contains<TSource>(this IOpt<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
TSource | value | A value to find in |
IEqualityComparer<TSource> | comparer | A comparer to determine whether values are equal. (If null, Default is used.) |
Returns
Type | Description |
---|---|
Boolean | true, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
The comparison, if any, is performed using comparer
. If comparer
is null, Default
for TSource
is used instead.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Count<TSource>(IOpt<TSource>)
Returns the number of elements in an option.
Declaration
public static int Count<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
Int32 | 1 if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Count<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the number of elements of an option that satisfy a predicate.
Declaration
public static int Count<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
Int32 | 1, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
DefaultIfEmpty<TSource>(IOpt<TSource>)
Returns a full option containing either the same contents as a specified option, if it is full, or the default value for the type, if it is empty.
Declaration
public static IOpt<TSource> DefaultIfEmpty<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option that is equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
DefaultIfEmpty<TSource>(IOpt<TSource>, TSource)
Returns a full option containing either the same contents as a specified option, if it is full, or a specified default value, if it is empty.
Declaration
public static IOpt<TSource> DefaultIfEmpty<TSource>(this IOpt<TSource> source, TSource defaultValue)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
TSource | defaultValue | A default value for the result to contain if |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option that is equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Distinct<TSource>(IOpt<TSource>)
Returns distinct elements from an option.
Declaration
public static IOpt<TSource> Distinct<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, never contains
duplicate elements, this method returns source
unmodified (after
ensuring that it is not null).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Distinct<TSource>(IOpt<TSource>, IEqualityComparer<TSource>)
Returns distinct elements from an option.
Declaration
public static IOpt<TSource> Distinct<TSource>(this IOpt<TSource> source, IEqualityComparer<TSource> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
IEqualityComparer<TSource> | comparer | A comparer used to test values for equality. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, never contains
duplicate elements, this method returns source
unmodified (after
ensuring that it is not null).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ElementAt<TSource>(IOpt<TSource>, Int32)
Returns the element at a specified index in an option.
Declaration
public static TSource ElementAt<TSource>(this IOpt<TSource> source, int index)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Int32 | index | The index of the element to retrieve. |
Returns
Type | Description |
---|---|
TSource | The element at the specified position in |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException |
|
ElementAtOrDefault<TSource>(IOpt<TSource>, Int32)
Returns the element at a specified index in an option or the type's default value if the index is out of range.
Declaration
public static TSource ElementAtOrDefault<TSource>(this IOpt<TSource> source, int index)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Int32 | index | The index of the element to retrieve. |
Returns
Type | Description |
---|---|
TSource | The default value of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ElementAtOrDefault<TSource>(IOpt<TSource>, Int32, TSource)
Returns the element at a specified index in an option or a default value if the index is out of range.
Declaration
public static TSource ElementAtOrDefault<TSource>(this IOpt<TSource> source, int index, TSource defaultValue)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Int32 | index | The index of the element to retrieve. |
TSource | defaultValue | A default value to return if |
Returns
Type | Description |
---|---|
TSource |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Except<TSource>(IOpt<TSource>, IEnumerable<TSource>)
Finds the elements of an option that do not appear in a sequence.
Declaration
public static IOpt<TSource> Except<TSource>(this IOpt<TSource> first, IEnumerable<TSource> second)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | first | An option whose elements are to be subtracted from. |
IEnumerable<TSource> | second | A sequence of elements to subtract from |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Except<TSource>(IOpt<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)
Finds the elements of an option that do not appear in a sequence, using the specified comparer to determine equality.
Declaration
public static IOpt<TSource> Except<TSource>(this IOpt<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | first | An option whose elements are to be subtracted from. |
IEnumerable<TSource> | second | A sequence of elements to subtract from |
IEqualityComparer<TSource> | comparer | A comparer to determine whether elements are equal. (If null, Default is used.) |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
First<TSource>(IOpt<TSource>)
Returns the first element of an option.
Declaration
public static TSource First<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
First<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the first element of an option that satisfies a condition.
Declaration
public static TSource First<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
FirstOrDefault<TSource>(IOpt<TSource>)
Returns the first element of an option, or the default value for the type if the option is empty.
Declaration
public static TSource FirstOrDefault<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
FirstOrDefault<TSource>(IOpt<TSource>, TSource)
Returns the first element of an option, or a specified default value if the option is empty.
Declaration
public static TSource FirstOrDefault<TSource>(this IOpt<TSource> source, TSource defaultValue)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
TSource | defaultValue | A default value to return if |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
FirstOrDefault<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the first element of an option that satisfies a condition, or the default value for the type if no such element is found.
Declaration
public static TSource FirstOrDefault<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
FirstOrDefault<TSource>(IOpt<TSource>, Func<TSource, Boolean>, TSource)
Returns the first element of an option that satisfies a condition, or a specified default value if no such element is found.
Declaration
public static TSource FirstOrDefault<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate, TSource defaultValue)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
TSource | defaultValue | A default value to return if |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Flatten<TSource>(IOpt<IOpt<TSource>>)
Collapses an option containing another option into a single option.
Declaration
public static IOpt<TSource> Flatten<TSource>(this IOpt<IOpt<TSource>> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<IOpt<TSource>> | source | An outer option containing an inner option. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to the inner option, if it exists; otherwise, an empty option. |
Type Parameters
Name | Description |
---|---|
TSource | The element type of the inner option. |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Flatten<TSource>(IOpt<Opt<TSource>>)
Collapses an option containing another option into a single option.
Declaration
public static IOpt<TSource> Flatten<TSource>(this IOpt<Opt<TSource>> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Opt<TSource>> | source | An outer option containing an inner option. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to the inner option, if it exists; otherwise, an empty option. |
Type Parameters
Name | Description |
---|---|
TSource | The element type of the inner option. |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupBy<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>)
Groups the elements of an option by a selected key.
Declaration
public static IOpt<IOptGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element. |
Returns
Type | Description |
---|---|
IOpt<IOptGrouping<TKey, TSource>> | An option that contains a grouping for the element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to group elements. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupBy<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>)
Groups the elements of an option by a selected key.
Declaration
public static IOpt<IOptGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element. |
IEqualityComparer<TKey> | comparer | A comparer to determine whether keys are equal. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<IOptGrouping<TKey, TSource>> | An option that contains a grouping for the element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to group elements. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupBy<TSource, TKey, TElement>(IOpt<TSource>, Func<TSource, TKey>, Func<TSource, TElement>)
Groups the projected elements of an option by a selected key.
Declaration
public static IOpt<IOptGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Func<TSource, TElement> | elementSelector | A function to transform an element of |
Returns
Type | Description |
---|---|
IOpt<IOptGrouping<TKey, TElement>> | An option that contains a grouping for the projected element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to group elements. |
TElement | The type of the transformed elements to include in the grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupBy<TSource, TKey, TElement>(IOpt<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, IEqualityComparer<TKey>)
Groups the projected elements of an option by a selected key.
Declaration
public static IOpt<IOptGrouping<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, IEqualityComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Func<TSource, TElement> | elementSelector | A function to transform an element of |
IEqualityComparer<TKey> | comparer | A comparer to determine whether keys are equal. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<IOptGrouping<TKey, TElement>> | An option that contains a grouping for the projected element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to group elements. |
TElement | The type of the transformed elements to include in the grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupBy<TSource, TKey, TResult>(IOpt<TSource>, Func<TSource, TKey>, Func<TKey, IOpt<TSource>, TResult>)
Groups the elements of an option by a selected key, then applies a transform to each grouping.
Declaration
public static IOpt<TResult> GroupBy<TSource, TKey, TResult>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IOpt<TSource>, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Func<TKey, IOpt<TSource>, TResult> | resultSelector | A function to select a result value for each grouping. |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to group elements. |
TResult | The type of the result value for each grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupBy<TSource, TKey, TResult>(IOpt<TSource>, Func<TSource, TKey>, Func<TKey, IOpt<TSource>, TResult>, IEqualityComparer<TKey>)
Groups the elements of an option by a selected key, then applies a transform to each grouping.
Declaration
public static IOpt<TResult> GroupBy<TSource, TKey, TResult>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, Func<TKey, IOpt<TSource>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Func<TKey, IOpt<TSource>, TResult> | resultSelector | A function to select a result value for each grouping. |
IEqualityComparer<TKey> | comparer | A comparer to determine whether keys are equal. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to group elements. |
TResult | The type of the result value for each grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupBy<TSource, TKey, TElement, TResult>(IOpt<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, Func<TKey, IOpt<TElement>, TResult>)
Groups the projected elements of an option by a selected key, then applies a transform to each grouping.
Declaration
public static IOpt<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IOpt<TElement>, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Func<TSource, TElement> | elementSelector | A function to transform an element of |
Func<TKey, IOpt<TElement>, TResult> | resultSelector | A function to select a result value for each grouping. |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to group elements. |
TElement | The type of the transformed elements to include in the grouping. |
TResult | The type of the result value for each grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupBy<TSource, TKey, TElement, TResult>(IOpt<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, Func<TKey, IOpt<TElement>, TResult>, IEqualityComparer<TKey>)
Groups the projected elements of an option by a selected key, then applies a transform to each grouping.
Declaration
public static IOpt<TResult> GroupBy<TSource, TKey, TElement, TResult>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TElement> elementSelector, Func<TKey, IOpt<TElement>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Func<TSource, TElement> | elementSelector | A function to transform an element of |
Func<TKey, IOpt<TElement>, TResult> | resultSelector | A function to select a result value for each grouping. |
IEqualityComparer<TKey> | comparer | A comparer to determine whether keys are equal. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to group elements. |
TElement | The type of the transformed elements to include in the grouping. |
TResult | The type of the result value for each grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupJoin<TOuter, TInner, TKey, TResult>(IOpt<TOuter>, IOpt<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, IOpt<TInner>, TResult>)
Joins each element of an outer option to a grouping of inner elements with matching keys, then applies a transform to each grouping.
Declaration
public static IOpt<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IOpt<TOuter> outer, IOpt<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IOpt<TInner>, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TOuter> | outer | The outer option to join. |
IOpt<TInner> | inner | The inner option to join. |
Func<TOuter, TKey> | outerKeySelector | A function to select the key that corresponds to an element of |
Func<TInner, TKey> | innerKeySelector | A function to select the key that corresponds to an element of |
Func<TOuter, IOpt<TInner>, TResult> | resultSelector | A function to select a result value for each grouping. |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TOuter | The type of the elements of |
TInner | The type of the elements of |
TKey | The type of the key used to match and group elements. |
TResult | The type of the result value for each grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupJoin<TOuter, TInner, TKey, TResult>(IOpt<TOuter>, IOpt<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, IOpt<TInner>, TResult>, IEqualityComparer<TKey>)
Joins each element of an outer option to a grouping of inner elements with matching keys, then applies a transform to each grouping.
Declaration
public static IOpt<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IOpt<TOuter> outer, IOpt<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IOpt<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TOuter> | outer | The outer option to join. |
IOpt<TInner> | inner | The inner option to join. |
Func<TOuter, TKey> | outerKeySelector | A function to select the key that corresponds to an element of |
Func<TInner, TKey> | innerKeySelector | A function to select the key that corresponds to an element of |
Func<TOuter, IOpt<TInner>, TResult> | resultSelector | A function to select a result value for each grouping. |
IEqualityComparer<TKey> | comparer | A comparer to determine whether keys are equal. (If null, Default is used.) |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TOuter | The type of the elements of |
TInner | The type of the elements of |
TKey | The type of the key used to match and group elements. |
TResult | The type of the result value for each grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupJoin<TOuter, TInner, TKey, TResult>(IOpt<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, IEnumerable<TInner>, TResult>)
Joins each element of an outer option to a grouping of inner elements with matching keys, then applies a transform to each grouping.
Declaration
public static IOpt<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IOpt<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TOuter> | outer | The outer option to join. |
IEnumerable<TInner> | inner | The inner sequence to join. |
Func<TOuter, TKey> | outerKeySelector | A function to select the key that corresponds to an element of |
Func<TInner, TKey> | innerKeySelector | A function to select the key that corresponds to an element of |
Func<TOuter, IEnumerable<TInner>, TResult> | resultSelector | A function to select a result value for each grouping. |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TOuter | The type of the elements of |
TInner | The type of the elements of |
TKey | The type of the key used to match and group elements. |
TResult | The type of the result value for each grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
GroupJoin<TOuter, TInner, TKey, TResult>(IOpt<TOuter>, IEnumerable<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, IEnumerable<TInner>, TResult>, IEqualityComparer<TKey>)
Joins each element of an outer option to a grouping of inner elements with matching keys, then applies a transform to each grouping.
Declaration
public static IOpt<TResult> GroupJoin<TOuter, TInner, TKey, TResult>(this IOpt<TOuter> outer, IEnumerable<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, IEnumerable<TInner>, TResult> resultSelector, IEqualityComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TOuter> | outer | The outer option to join. |
IEnumerable<TInner> | inner | The inner sequence to join. |
Func<TOuter, TKey> | outerKeySelector | A function to select the key that corresponds to an element of |
Func<TInner, TKey> | innerKeySelector | A function to select the key that corresponds to an element of |
Func<TOuter, IEnumerable<TInner>, TResult> | resultSelector | A function to select a result value for each grouping. |
IEqualityComparer<TKey> | comparer | A comparer to determine whether keys are equal. (If null, Default is used.) |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TOuter | The type of the elements of |
TInner | The type of the elements of |
TKey | The type of the key used to match and group elements. |
TResult | The type of the result value for each grouping. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Intersect<TSource>(IOpt<TSource>, IEnumerable<TSource>)
Finds the elements of an option that also appear in a sequence.
Declaration
public static IOpt<TSource> Intersect<TSource>(this IOpt<TSource> first, IEnumerable<TSource> second)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | first | An option whose elements are to be compared. |
IEnumerable<TSource> | second | A sequence of elements to be compared. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Intersect<TSource>(IOpt<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)
Finds the elements of an option that also appear in a sequence, using the specified comparer to determine equality.
Declaration
public static IOpt<TSource> Intersect<TSource>(this IOpt<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | first | An option whose elements are to be compared. |
IEnumerable<TSource> | second | A sequence of elements to be compared. |
IEqualityComparer<TSource> | comparer | A comparer to determine whether elements are equal. (If null, Default is used.) |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Join<TOuter, TInner, TKey, TResult>(IOpt<TOuter>, IOpt<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, TInner, TResult>)
Joins elements of an outer option with elements of an inner option having matching keys.
Declaration
public static IOpt<TResult> Join<TOuter, TInner, TKey, TResult>(this IOpt<TOuter> outer, IOpt<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TOuter> | outer | The outer option to join. |
IOpt<TInner> | inner | The inner option to join. |
Func<TOuter, TKey> | outerKeySelector | A function to select the key that corresponds to an element of |
Func<TInner, TKey> | innerKeySelector | A function to select the key that corresponds to an element of |
Func<TOuter, TInner, TResult> | resultSelector | A function to select a result value for each matched pair. |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TOuter | The type of the elements of |
TInner | The type of the elements of |
TKey | The type of the key used to match elements. |
TResult | The type of the result value for each matched pair. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Join<TOuter, TInner, TKey, TResult>(IOpt<TOuter>, IOpt<TInner>, Func<TOuter, TKey>, Func<TInner, TKey>, Func<TOuter, TInner, TResult>, IEqualityComparer<TKey>)
Joins elements of an outer option with elements of an inner option having matching keys.
Declaration
public static IOpt<TResult> Join<TOuter, TInner, TKey, TResult>(this IOpt<TOuter> outer, IOpt<TInner> inner, Func<TOuter, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<TOuter, TInner, TResult> resultSelector, IEqualityComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TOuter> | outer | The outer option to join. |
IOpt<TInner> | inner | The inner option to join. |
Func<TOuter, TKey> | outerKeySelector | A function to select the key that corresponds to an element of |
Func<TInner, TKey> | innerKeySelector | A function to select the key that corresponds to an element of |
Func<TOuter, TInner, TResult> | resultSelector | A function to select a result value for each matched pair. |
IEqualityComparer<TKey> | comparer | A comparer to determine whether keys are equal. (If null, Default is used.) |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option that contains the result of applying |
Type Parameters
Name | Description |
---|---|
TOuter | The type of the elements of |
TInner | The type of the elements of |
TKey | The type of the key used to match elements. |
TResult | The type of the result value for each matched pair. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Last<TSource>(IOpt<TSource>)
Returns the first element of an option.
Declaration
public static TSource Last<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Last<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the first element of an option that satisfies a condition.
Declaration
public static TSource Last<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
LastOrDefault<TSource>(IOpt<TSource>)
Returns the first element of an option, or the default value for the type if the option is empty.
Declaration
public static TSource LastOrDefault<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
LastOrDefault<TSource>(IOpt<TSource>, TSource)
Returns the first element of an option, or a specified default value if the option is empty.
Declaration
public static TSource LastOrDefault<TSource>(this IOpt<TSource> source, TSource defaultValue)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
TSource | defaultValue | A default value to return if |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
LastOrDefault<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the first element of an option that satisfies a condition, or the default value for the type if no such element is found.
Declaration
public static TSource LastOrDefault<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
LastOrDefault<TSource>(IOpt<TSource>, Func<TSource, Boolean>, TSource)
Returns the first element of an option that satisfies a condition, or a specified default value if no such element is found.
Declaration
public static TSource LastOrDefault<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate, TSource defaultValue)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
TSource | defaultValue | A default value to return if |
Returns
Type | Description |
---|---|
TSource | The first element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
LongCount<TSource>(IOpt<TSource>)
Returns the number of elements in an option.
Declaration
public static long LongCount<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
Int64 | 1 if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
LongCount<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the number of elements of an option that satisfy a predicate.
Declaration
public static long LongCount<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
Int64 | 1, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Match<TSource, TResult>(IOpt<TSource>, Func<TResult>, Func<TSource, TResult>)
Converts this option to another value based on its contents.
Declaration
public static TResult Match<TSource, TResult>(this IOpt<TSource> source, Func<TResult> ifEmpty = null, Func<TSource, TResult> ifFull = null)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TResult> | ifEmpty | A function to produce the result if this option is empty. |
Func<TSource, TResult> | ifFull | A function to produce the result if this option is full, which accepts the contained element as a parameter. |
Returns
Type | Description |
---|---|
TResult | The result of calling |
Type Parameters
Name | Description |
---|---|
TSource | The element type of |
TResult | The result type for this conversion. |
Remarks
This operation is performed immediately rather than by deferred execution. Compare MatchOpt<TSource, TResult>(IOpt<TSource>, Func<Opt<TResult>>, Func<TSource, Opt<TResult>>), which uses deferred execution.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
MatchOpt<TSource, TResult>(IOpt<TSource>, Func<Opt<TResult>>, Func<TSource, Opt<TResult>>)
Converts this option to another option based on its contents.
Declaration
public static IOpt<TResult> MatchOpt<TSource, TResult>(this IOpt<TSource> source, Func<Opt<TResult>> ifEmpty = null, Func<TSource, Opt<TResult>> ifFull = null)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<Opt<TResult>> | ifEmpty | A function to produce the result if this option is empty. |
Func<TSource, Opt<TResult>> | ifFull | A function to produce the result if this option is full, which accepts the contained element as a parameter. |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option equivalent to the result of calling |
Type Parameters
Name | Description |
---|---|
TSource | The element type of |
TResult | The element type for the result of this conversion. |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Compare Match<TSource, TResult>(IOpt<TSource>, Func<TResult>, Func<TSource, TResult>), which uses immediate execution.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max(IOpt<Decimal>)
Returns the maximum value in an option.
Declaration
public static decimal Max(this IOpt<decimal> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Decimal> | source | A source option. |
Returns
Type | Description |
---|---|
Decimal | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max(IOpt<Double>)
Returns the maximum value in an option.
Declaration
public static double Max(this IOpt<double> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Double> | source | A source option. |
Returns
Type | Description |
---|---|
Double | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max(IOpt<Int32>)
Returns the maximum value in an option.
Declaration
public static int Max(this IOpt<int> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Int32> | source | A source option. |
Returns
Type | Description |
---|---|
Int32 | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max(IOpt<Int64>)
Returns the maximum value in an option.
Declaration
public static long Max(this IOpt<long> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Int64> | source | A source option. |
Returns
Type | Description |
---|---|
Int64 | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max(IOpt<Nullable<Decimal>>)
Returns the maximum value in an option.
Declaration
public static decimal? Max(this IOpt<decimal? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Decimal>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max(IOpt<Nullable<Double>>)
Returns the maximum value in an option.
Declaration
public static double? Max(this IOpt<double? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Double>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Double> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max(IOpt<Nullable<Int32>>)
Returns the maximum value in an option.
Declaration
public static int? Max(this IOpt<int? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Int32>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Int32> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max(IOpt<Nullable<Int64>>)
Returns the maximum value in an option.
Declaration
public static long? Max(this IOpt<long? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Int64>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Int64> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max(IOpt<Nullable<Single>>)
Returns the maximum value in an option.
Declaration
public static float? Max(this IOpt<float? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Single>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Single> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max(IOpt<Single>)
Returns the maximum value in an option.
Declaration
public static float Max(this IOpt<float> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Single> | source | A source option. |
Returns
Type | Description |
---|---|
Single | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max<TSource>(IOpt<TSource>)
Returns the maximum value in an option.
Declaration
public static TSource Max<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
TSource | The only element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Decimal>)
Returns the maximum value in the projection of an option.
Declaration
public static decimal Max<TSource>(this IOpt<TSource> source, Func<TSource, decimal> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Decimal> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Decimal | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Double>)
Returns the maximum value in the projection of an option.
Declaration
public static double Max<TSource>(this IOpt<TSource> source, Func<TSource, double> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Double> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Double | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Int32>)
Returns the maximum value in the projection of an option.
Declaration
public static int Max<TSource>(this IOpt<TSource> source, Func<TSource, int> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Int32 | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Int64>)
Returns the maximum value in the projection of an option.
Declaration
public static long Max<TSource>(this IOpt<TSource> source, Func<TSource, long> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int64> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Int64 | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Nullable<Decimal>>)
Returns the maximum value in the projection of an option.
Declaration
public static decimal? Max<TSource>(this IOpt<TSource> source, Func<TSource, decimal? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Decimal>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Nullable<Double>>)
Returns the maximum value in the projection of an option.
Declaration
public static double? Max<TSource>(this IOpt<TSource> source, Func<TSource, double? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Double>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Double> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Nullable<Int32>>)
Returns the maximum value in the projection of an option.
Declaration
public static int? Max<TSource>(this IOpt<TSource> source, Func<TSource, int? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Int32>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Int32> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Nullable<Int64>>)
Returns the maximum value in the projection of an option.
Declaration
public static long? Max<TSource>(this IOpt<TSource> source, Func<TSource, long? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Int64>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Int64> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Nullable<Single>>)
Returns the maximum value in the projection of an option.
Declaration
public static float? Max<TSource>(this IOpt<TSource> source, Func<TSource, float? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Single>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Single> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Max<TSource>(IOpt<TSource>, Func<TSource, Single>)
Returns the maximum value in the projection of an option.
Declaration
public static float Max<TSource>(this IOpt<TSource> source, Func<TSource, float> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Single> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Single | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Max<TSource, TResult>(IOpt<TSource>, Func<TSource, TResult>)
Returns the maximum value in the projection of an option.
Declaration
public static TResult Max<TSource, TResult>(this IOpt<TSource> source, Func<TSource, TResult> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TResult> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
TResult | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TResult |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min(IOpt<Decimal>)
Returns the minimum value in an option.
Declaration
public static decimal Min(this IOpt<decimal> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Decimal> | source | A source option. |
Returns
Type | Description |
---|---|
Decimal | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min(IOpt<Double>)
Returns the minimum value in an option.
Declaration
public static double Min(this IOpt<double> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Double> | source | A source option. |
Returns
Type | Description |
---|---|
Double | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min(IOpt<Int32>)
Returns the minimum value in an option.
Declaration
public static int Min(this IOpt<int> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Int32> | source | A source option. |
Returns
Type | Description |
---|---|
Int32 | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min(IOpt<Int64>)
Returns the minimum value in an option.
Declaration
public static long Min(this IOpt<long> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Int64> | source | A source option. |
Returns
Type | Description |
---|---|
Int64 | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min(IOpt<Nullable<Decimal>>)
Returns the minimum value in an option.
Declaration
public static decimal? Min(this IOpt<decimal? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Decimal>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min(IOpt<Nullable<Double>>)
Returns the minimum value in an option.
Declaration
public static double? Min(this IOpt<double? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Double>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Double> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min(IOpt<Nullable<Int32>>)
Returns the minimum value in an option.
Declaration
public static int? Min(this IOpt<int? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Int32>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Int32> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min(IOpt<Nullable<Int64>>)
Returns the minimum value in an option.
Declaration
public static long? Min(this IOpt<long? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Int64>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Int64> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min(IOpt<Nullable<Single>>)
Returns the minimum value in an option.
Declaration
public static float? Min(this IOpt<float? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Single>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Single> | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min(IOpt<Single>)
Returns the minimum value in an option.
Declaration
public static float Min(this IOpt<float> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Single> | source | A source option. |
Returns
Type | Description |
---|---|
Single | The only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min<TSource>(IOpt<TSource>)
Returns the minimum value in an option.
Declaration
public static TSource Min<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
TSource | The only element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Decimal>)
Returns the minimum value in the projection of an option.
Declaration
public static decimal Min<TSource>(this IOpt<TSource> source, Func<TSource, decimal> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Decimal> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Decimal | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Double>)
Returns the minimum value in the projection of an option.
Declaration
public static double Min<TSource>(this IOpt<TSource> source, Func<TSource, double> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Double> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Double | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Int32>)
Returns the minimum value in the projection of an option.
Declaration
public static int Min<TSource>(this IOpt<TSource> source, Func<TSource, int> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Int32 | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Int64>)
Returns the minimum value in the projection of an option.
Declaration
public static long Min<TSource>(this IOpt<TSource> source, Func<TSource, long> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int64> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Int64 | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Nullable<Decimal>>)
Returns the minimum value in the projection of an option.
Declaration
public static decimal? Min<TSource>(this IOpt<TSource> source, Func<TSource, decimal? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Decimal>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Nullable<Double>>)
Returns the minimum value in the projection of an option.
Declaration
public static double? Min<TSource>(this IOpt<TSource> source, Func<TSource, double? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Double>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Double> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Nullable<Int32>>)
Returns the minimum value in the projection of an option.
Declaration
public static int? Min<TSource>(this IOpt<TSource> source, Func<TSource, int? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Int32>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Int32> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Nullable<Int64>>)
Returns the minimum value in the projection of an option.
Declaration
public static long? Min<TSource>(this IOpt<TSource> source, Func<TSource, long? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Int64>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Int64> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Nullable<Single>>)
Returns the minimum value in the projection of an option.
Declaration
public static float? Min<TSource>(this IOpt<TSource> source, Func<TSource, float? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Single>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Single> | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Min<TSource>(IOpt<TSource>, Func<TSource, Single>)
Returns the minimum value in the projection of an option.
Declaration
public static float Min<TSource>(this IOpt<TSource> source, Func<TSource, float> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Single> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Single | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Min<TSource, TResult>(IOpt<TSource>, Func<TSource, TResult>)
Returns the minimum value in the projection of an option.
Declaration
public static TResult Min<TSource, TResult>(this IOpt<TSource> source, Func<TSource, TResult> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TResult> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
TResult | The result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TResult |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
OfType<TResult>(IOpt)
Filters the elements of an option to those of a specified type.
Declaration
public static IOpt<TResult> OfType<TResult>(this IOpt source)
Parameters
Type | Name | Description |
---|---|---|
IOpt | source | A source option. |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option having the same contents as |
Type Parameters
Name | Description |
---|---|
TResult | The type to which to filter the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
OrderBy<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>)
Sorts the elements of an option in ascending order.
Declaration
public static IOpt<TSource> OrderBy<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to compare elements. |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is trivially already
ordered, this method returns source
unmodified (after null-checking any required parameters).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
OrderBy<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>, IComparer<TKey>)
Sorts the elements of an option in ascending order.
Declaration
public static IOpt<TSource> OrderBy<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
IComparer<TKey> | comparer | A comparer used to order keys. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to compare elements. |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is trivially already
ordered, this method returns source
unmodified (after null-checking any required parameters).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
OrderByDescending<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>)
Sorts the elements of an option in descending order.
Declaration
public static IOpt<TSource> OrderByDescending<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to compare elements. |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is trivially already
ordered, this method returns source
unmodified (after null-checking any required parameters).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
OrderByDescending<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>, IComparer<TKey>)
Sorts the elements of an option in descending order.
Declaration
public static IOpt<TSource> OrderByDescending<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
IComparer<TKey> | comparer | A comparer used to order keys. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to compare elements. |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is trivially already
ordered, this method returns source
unmodified (after null-checking any required parameters).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ReplaceIfEmpty<TSource>(IOpt<TSource>, IOpt<TSource>)
Substitutes the specified replacement option if this option is empty.
Declaration
public static IOpt<TSource> ReplaceIfEmpty<TSource>(this IOpt<TSource> source, IOpt<TSource> replacement)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
IOpt<TSource> | replacement | An option to produce the result if |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The element type of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ReplaceIfEmpty<TSource>(IOpt<TSource>, Func<IOpt<TSource>>)
Substitutes the result of a callback if this option is empty.
Declaration
public static IOpt<TSource> ReplaceIfEmpty<TSource>(this IOpt<TSource> source, Func<IOpt<TSource>> replacementFactory)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<IOpt<TSource>> | replacementFactory | A function to produce the result if |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The element type of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Reverse<TSource>(IOpt<TSource>)
Inverts the order of contents of an option.
Declaration
public static IOpt<TSource> Reverse<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is its own reverse,
this method returns source
unmodified (after ensuring that it is not
null).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Select<TSource, TResult>(IOpt<TSource>, Func<TSource, TResult>)
Produces a projection of an option by applying a transformation function to its contents.
Declaration
public static IOpt<TResult> Select<TSource, TResult>(this IOpt<TSource> source, Func<TSource, TResult> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TResult> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
IOpt<TResult> | A full option containing the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TResult | The type of the elements of the result option. |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Select<TSource, TResult>(IOpt<TSource>, Func<TSource, Int32, TResult>)
Produces a projection of an option by applying a transformation function to its contents.
Declaration
public static IOpt<TResult> Select<TSource, TResult>(this IOpt<TSource> source, Func<TSource, int, TResult> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32, TResult> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
IOpt<TResult> | A full option containing the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TResult | The type of the elements of the result option. |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SelectMany<TSource, TResult>(IOpt<TSource>, Func<TSource, IOpt<TResult>>)
Projects each element of an option to a new option and flattens the result.
Declaration
public static IOpt<TResult> SelectMany<TSource, TResult>(this IOpt<TSource> source, Func<TSource, IOpt<TResult>> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, IOpt<TResult>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
IOpt<TResult> | A full option equivalent to the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TResult | The type of the elements of the option returned by |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SelectMany<TSource, TResult>(IOpt<TSource>, Func<TSource, Int32, IOpt<TResult>>)
Projects each element of an option to a new option and flattens the result.
Declaration
public static IOpt<TResult> SelectMany<TSource, TResult>(this IOpt<TSource> source, Func<TSource, int, IOpt<TResult>> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32, IOpt<TResult>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
IOpt<TResult> | A full option equivalent to the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TResult | The type of the elements of the option returned by |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SelectMany<TSource, TCollection, TResult>(IOpt<TSource>, Func<TSource, IOpt<TCollection>>, Func<TSource, TCollection, TResult>)
Projects each element of an option to a new option and flattens the result, then applies a transform to the result elements.
Declaration
public static IOpt<TResult> SelectMany<TSource, TCollection, TResult>(this IOpt<TSource> source, Func<TSource, IOpt<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, IOpt<TCollection>> | collectionSelector | A transform function applied to each element of |
Func<TSource, TCollection, TResult> | resultSelector | A transform function applied to each element of each intermediate option returned by
|
Returns
Type | Description |
---|---|
IOpt<TResult> | A full option containing the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TCollection | The type of the elements of the intermediate option produced by applying |
TResult | The type of the elements of the result option. |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SelectMany<TSource, TCollection, TResult>(IOpt<TSource>, Func<TSource, Int32, IOpt<TCollection>>, Func<TSource, TCollection, TResult>)
Projects each element of an option to a new option and flattens the result, then applies a transform to the result elements.
Declaration
public static IOpt<TResult> SelectMany<TSource, TCollection, TResult>(this IOpt<TSource> source, Func<TSource, int, IOpt<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32, IOpt<TCollection>> | collectionSelector | A transform function applied to each element of |
Func<TSource, TCollection, TResult> | resultSelector | A transform function applied to each element of each intermediate option returned by
|
Returns
Type | Description |
---|---|
IOpt<TResult> | A full option containing the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TCollection | The type of the elements of the intermediate option produced by applying |
TResult | The type of the elements of the result option. |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SequenceEqual<TSource>(IOpt<TSource>, IEnumerable<TSource>)
Determines whether an option has an equal length and sequence of elements to a sequence.
Declaration
public static bool SequenceEqual<TSource>(this IOpt<TSource> first, IEnumerable<TSource> second)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | first | A source option. |
IEnumerable<TSource> | second | A sequence whose contents to compare with those of |
Returns
Type | Description |
---|---|
Boolean | true if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SequenceEqual<TSource>(IOpt<TSource>, IEnumerable<TSource>, IEqualityComparer<TSource>)
Determines whether an option has an equal length and sequence of elements to a sequence.
Declaration
public static bool SequenceEqual<TSource>(this IOpt<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | first | A source option. |
IEnumerable<TSource> | second | A sequence whose contents to compare with those of |
IEqualityComparer<TSource> | comparer | A comparer to determine whether values are equal. (If null, Default is used.) |
Returns
Type | Description |
---|---|
Boolean | true if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Single<TSource>(IOpt<TSource>)
Returns the only element of an option.
Declaration
public static TSource Single<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Returns
Type | Description |
---|---|
TSource | The only element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
Single<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the only element of an option that satisfies a condition.
Declaration
public static TSource Single<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | The only element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
InvalidOperationException |
|
SingleOrDefault<TSource>(IOpt<TSource>)
Returns the only element of an option, or the default value for the type if the option is empty.
Declaration
public static TSource SingleOrDefault<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Returns
Type | Description |
---|---|
TSource | The only element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SingleOrDefault<TSource>(IOpt<TSource>, TSource)
Returns the only element of an option, or a specified default value if the option is empty.
Declaration
public static TSource SingleOrDefault<TSource>(this IOpt<TSource> source, TSource defaultValue)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
TSource | defaultValue | A default value to return if |
Returns
Type | Description |
---|---|
TSource | The only element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SingleOrDefault<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the only element of an option that satisfies a condition, or the default value for the type if no such element is found.
Declaration
public static TSource SingleOrDefault<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | The only element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SingleOrDefault<TSource>(IOpt<TSource>, Func<TSource, Boolean>, TSource)
Returns the only element of an option that satisfies a condition, or a specified default value if no such element is found.
Declaration
public static TSource SingleOrDefault<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate, TSource defaultValue)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to return an element from. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
TSource | defaultValue | A default value to return if |
Returns
Type | Description |
---|---|
TSource | The only element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Skip<TSource>(IOpt<TSource>, Int32)
Returns the remaining contents of an option after skipping a specified number of elements.
Declaration
public static IOpt<TSource> Skip<TSource>(this IOpt<TSource> source, int count)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Int32 | count | The number of elements to skip. |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
If count
is zero or negative, no elements are skipped. If count
is greater than or equal to the number of elements of source
, all
elements are skipped.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SkipWhile<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns the first element of an option that does not satisfy a predicate and all following elements.
Declaration
public static IOpt<TSource> SkipWhile<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An empty option, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
If all elements of source
satisfy predicate
, the
result is empty.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
SkipWhile<TSource>(IOpt<TSource>, Func<TSource, Int32, Boolean>)
Returns the first element of an option that does not satisfy a predicate and all following elements.
Declaration
public static IOpt<TSource> SkipWhile<TSource>(this IOpt<TSource> source, Func<TSource, int, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32, Boolean> | predicate | A function to test each element and its index for a condition. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An empty option, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
If all elements of source
satisfy predicate
, the
result is empty.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Decimal>)
Computes the sum of the contents of an option.
Declaration
public static decimal Sum(this IOpt<decimal> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Decimal> | source | A source option. |
Returns
Type | Description |
---|---|
Decimal | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Double>)
Computes the sum of the contents of an option.
Declaration
public static double Sum(this IOpt<double> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Double> | source | A source option. |
Returns
Type | Description |
---|---|
Double | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Int32>)
Computes the sum of the contents of an option.
Declaration
public static int Sum(this IOpt<int> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Int32> | source | A source option. |
Returns
Type | Description |
---|---|
Int32 | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Int64>)
Computes the sum of the contents of an option.
Declaration
public static long Sum(this IOpt<long> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Int64> | source | A source option. |
Returns
Type | Description |
---|---|
Int64 | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Nullable<Decimal>>)
Computes the sum of the non-null contents of an option.
Declaration
public static decimal? Sum(this IOpt<decimal? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Decimal>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Nullable<Double>>)
Computes the sum of the non-null contents of an option.
Declaration
public static double? Sum(this IOpt<double? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Double>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Double> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Nullable<Int32>>)
Computes the sum of the non-null contents of an option.
Declaration
public static int? Sum(this IOpt<int? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Int32>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Int32> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Nullable<Int64>>)
Computes the sum of the non-null contents of an option.
Declaration
public static long? Sum(this IOpt<long? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Int64>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Int64> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Nullable<Single>>)
Computes the sum of the non-null contents of an option.
Declaration
public static float? Sum(this IOpt<float? > source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<Single>> | source | A source option. |
Returns
Type | Description |
---|---|
Nullable<Single> | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum(IOpt<Single>)
Computes the sum of the contents of an option.
Declaration
public static float Sum(this IOpt<float> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<Single> | source | A source option. |
Returns
Type | Description |
---|---|
Single | The value of the only element of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum<TSource>(IOpt<TSource>, Func<TSource, Decimal>)
Computes the sum of a projection of the contents of an option.
Declaration
public static decimal Sum<TSource>(this IOpt<TSource> source, Func<TSource, decimal> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Decimal> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Decimal | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum<TSource>(IOpt<TSource>, Func<TSource, Double>)
Computes the sum of a projection of the contents of an option.
Declaration
public static double Sum<TSource>(this IOpt<TSource> source, Func<TSource, double> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Double> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Double | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum<TSource>(IOpt<TSource>, Func<TSource, Int32>)
Computes the sum of a projection of the contents of an option.
Declaration
public static int Sum<TSource>(this IOpt<TSource> source, Func<TSource, int> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Int32 | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum<TSource>(IOpt<TSource>, Func<TSource, Int64>)
Computes the sum of a projection of the contents of an option.
Declaration
public static long Sum<TSource>(this IOpt<TSource> source, Func<TSource, long> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int64> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Int64 | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Sum<TSource>(IOpt<TSource>, Func<TSource, Nullable<Decimal>>)
Computes the sum of the non-null elements of a projection of the contents of an option.
Declaration
public static decimal? Sum<TSource>(this IOpt<TSource> source, Func<TSource, decimal? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Decimal>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Decimal> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Sum<TSource>(IOpt<TSource>, Func<TSource, Nullable<Double>>)
Computes the sum of the non-null elements of a projection of the contents of an option.
Declaration
public static double? Sum<TSource>(this IOpt<TSource> source, Func<TSource, double? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Double>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Double> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Sum<TSource>(IOpt<TSource>, Func<TSource, Nullable<Int32>>)
Computes the sum of the non-null elements of a projection of the contents of an option.
Declaration
public static int? Sum<TSource>(this IOpt<TSource> source, Func<TSource, int? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Int32>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Int32> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Sum<TSource>(IOpt<TSource>, Func<TSource, Nullable<Int64>>)
Computes the sum of the non-null elements of a projection of the contents of an option.
Declaration
public static long? Sum<TSource>(this IOpt<TSource> source, Func<TSource, long? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Int64>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Int64> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Sum<TSource>(IOpt<TSource>, Func<TSource, Nullable<Single>>)
Computes the sum of the non-null elements of a projection of the contents of an option.
Declaration
public static float? Sum<TSource>(this IOpt<TSource> source, Func<TSource, float? > selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Nullable<Single>> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Nullable<Single> | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Sum<TSource>(IOpt<TSource>, Func<TSource, Single>)
Computes the sum of a projection of the contents of an option.
Declaration
public static float Sum<TSource>(this IOpt<TSource> source, Func<TSource, float> selector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Single> | selector | A transform function applied to each element of |
Returns
Type | Description |
---|---|
Single | The value of the result of applying |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Take<TSource>(IOpt<TSource>, Int32)
Returns the specified number of elements from an option.
Declaration
public static IOpt<TSource> Take<TSource>(this IOpt<TSource> source, int count)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Int32 | count | The number of elements to return. |
Returns
Type | Description |
---|---|
IOpt<TSource> |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
If count
is zero or negative, no elements are returned. If count
is greater than or equal to the number of elements of source
, all elements are returned.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
TakeWhile<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Returns all elements of an option before the first element that does not satisfy a predicate.
Declaration
public static IOpt<TSource> TakeWhile<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An empty option, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
If no elements of source
satisfy predicate
, the
result is empty.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
TakeWhile<TSource>(IOpt<TSource>, Func<TSource, Int32, Boolean>)
Returns all elements of an option before the first element that does not satisfy a predicate.
Declaration
public static IOpt<TSource> TakeWhile<TSource>(this IOpt<TSource> source, Func<TSource, int, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32, Boolean> | predicate | A function to test each element and its index for a condition. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An empty option, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ThenBy<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>)
Subsequently sorts the elements of an already ordered option in ascending order.
Declaration
public static IOpt<TSource> ThenBy<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to compare elements. |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is trivially already
ordered, this method returns source
unmodified (after null-checking any required parameters).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ThenBy<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>, IComparer<TKey>)
Subsequently sorts the elements of an already ordered option in ascending order.
Declaration
public static IOpt<TSource> ThenBy<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
IComparer<TKey> | comparer | A comparer used to order keys. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to compare elements. |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is trivially already
ordered, this method returns source
unmodified (after null-checking any required parameters).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ThenByDescending<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>)
Subsequently sorts the elements of an already ordered option in descending order.
Declaration
public static IOpt<TSource> ThenByDescending<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to compare elements. |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is trivially already
ordered, this method returns source
unmodified (after null-checking any required parameters).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ThenByDescending<TSource, TKey>(IOpt<TSource>, Func<TSource, TKey>, IComparer<TKey>)
Subsequently sorts the elements of an already ordered option in descending order.
Declaration
public static IOpt<TSource> ThenByDescending<TSource, TKey>(this IOpt<TSource> source, Func<TSource, TKey> keySelector, IComparer<TKey> comparer)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, TKey> | keySelector | A function to select the key that corresponds to an element of |
IComparer<TKey> | comparer | A comparer used to order keys. (This parameter is ignored.) |
Returns
Type | Description |
---|---|
IOpt<TSource> |
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
TKey | The type of the key used to compare elements. |
Remarks
Since an option, by virtue of being a zero- or one-element sequence, is trivially already
ordered, this method returns source
unmodified (after null-checking any required parameters).
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ToArray<TSource>(IOpt<TSource>)
Creates a new array having the same contents as an option.
Declaration
public static TSource[] ToArray<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
TSource[] | A new single-element array containing the element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ToFixed(IOpt)
Returns a fixed option reflecting the current state of an option.
Declaration
public static Opt<object> ToFixed(this IOpt source)
Parameters
Type | Name | Description |
---|---|---|
IOpt | source | A source option. |
Returns
Type | Description |
---|---|
Opt<Object> | A fixed option reflecting the current state of |
ToFixed<TSource>(IOpt<TSource>)
Returns a fixed option reflecting the current state of an option.
Declaration
public static Opt<TSource> ToFixed<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
Opt<TSource> | A fixed option reflecting the current state of |
Type Parameters
Name | Description |
---|---|
TSource | The element type of |
ToList<TSource>(IOpt<TSource>)
Creates a new list having the same contents as an option.
Declaration
public static List<TSource> ToList<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Returns
Type | Description |
---|---|
List<TSource> | A new single-element list containing the element of |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
TryGetValue<TSource>(IOpt<TSource>, out TSource)
Gets the value contained by an option, if it exists.
Declaration
public static bool TryGetValue<TSource>(this IOpt<TSource> source, out TSource value)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option whose value to get. |
TSource | value | When this method returns, is set to the value contained by |
Returns
Type | Description |
---|---|
Boolean | true, if source contains a value; otherwise, false. |
Type Parameters
Name | Description |
---|---|
TSource | The element type of source. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Where<TSource>(IOpt<TSource>, Func<TSource, Boolean>)
Filters the elements of an option to those that satisfy a predicate.
Declaration
public static IOpt<TSource> Where<TSource>(this IOpt<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Boolean> | predicate | A function to test an element of |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option containing the same element as source, if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Where<TSource>(IOpt<TSource>, Func<TSource, Int32, Boolean>)
Filters the elements of an option to those that satisfy a predicate.
Declaration
public static IOpt<TSource> Where<TSource>(this IOpt<TSource> source, Func<TSource, int, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | A source option. |
Func<TSource, Int32, Boolean> | predicate | A function to test an element of |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option containing the same element as |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
WhereNotNull<TSource>(IOpt<TSource>)
Filters the contents of an option to include only non- null values.
Declaration
public static IOpt<TSource> WhereNotNull<TSource>(this IOpt<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TSource> | source | An option to filter. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option equivalent to |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
WhereNotNullSelectValue<TSource>(IOpt<Nullable<TSource>>)
Filters the contents of an option to include only non- null values, converting the results to their non-nullable type.
Declaration
public static IOpt<TSource> WhereNotNullSelectValue<TSource>(this IOpt<TSource? > source)
where TSource : struct
Parameters
Type | Name | Description |
---|---|---|
IOpt<Nullable<TSource>> | source | An option to filter. |
Returns
Type | Description |
---|---|
IOpt<TSource> | An option containing the same value as source, if it is full and contains a non- null value; otherwise, an empty option. |
Type Parameters
Name | Description |
---|---|
TSource | The non-nullable basis type of the type of the elements of |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Zip<TFirst, TSecond, TResult>(IOpt<TFirst>, IEnumerable<TSecond>, Func<TFirst, TSecond, TResult>)
Produces a new option by combining the value from an option with the value from another source using the specified result selector.
Declaration
public static IOpt<TResult> Zip<TFirst, TSecond, TResult>(this IOpt<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IOpt<TFirst> | first | The first source. |
IEnumerable<TSecond> | second | The second source. |
Func<TFirst, TSecond, TResult> | resultSelector | A function that specifies how to combine an element from |
Returns
Type | Description |
---|---|
IOpt<TResult> | An option containing the result of calling |
Type Parameters
Name | Description |
---|---|
TFirst | The type of the elements of |
TSecond | The type of the elements of |
TResult | The type of the elements of the result option. |
Remarks
This method is implemented using deferred execution; the query represented by this method is not performed until the contents of the returned option are resolved, such as by enumeration.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|