Class EnumerableExtensions
- Namespace
- Olve.Utilities.CollectionExtensions
- Assembly
- Olve.Utilities.dll
Provides extension methods for enumerables.
public static class EnumerableExtensions
- Inheritance
-
EnumerableExtensions
- Inherited Members
Methods
ForEach<T>(IEnumerable<T>, Action<T>)
Performs an action on each item in the enumerable.
public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
Parameters
enumerableIEnumerable<T>The enumerable to perform the action on.
actionAction<T>The action to perform on each item.
Type Parameters
TThe type of the items in the enumerable.
Remarks
Please note that this method is not lazy and will execute the action on each item immediately.
ForEach<TIn, TOut>(IEnumerable<TIn>, Func<TIn, TOut>)
Performs an action on each item in the enumerable.
public static IEnumerable<TOut> ForEach<TIn, TOut>(this IEnumerable<TIn> enumerable, Func<TIn, TOut> action)
Parameters
enumerableIEnumerable<TIn>The enumerable to perform the action on.
actionFunc<TIn, TOut>The action to perform on each item.
Returns
- IEnumerable<TOut>
An enumerable of the results of the action.
Type Parameters
TInThe type of the items in the enumerable.
TOutThe type of the items in the resulting enumerable.
Remarks
Please note that this method is lazy and will not execute the action on each item until the enumerable is enumerated.
Product(IEnumerable<float>)
Returns the product of all the items in the enumerable.
public static float Product(this IEnumerable<float> enumerable)
Parameters
enumerableIEnumerable<float>The enumerable to calculate the product of.
Returns
- float
The product of all the items in the enumerable.
TryAsReadOnlySet<T>(IEnumerable<T>, out IReadOnlySet<T>?)
Attempts to cast an IEnumerable<T> to an IReadOnlySet<T>.
public static bool TryAsReadOnlySet<T>(this IEnumerable<T> enumerable, out IReadOnlySet<T>? readOnlySet)
Parameters
enumerableIEnumerable<T>The enumerable to attempt to cast.
readOnlySetIReadOnlySet<T>When this method returns, contains the resulting IReadOnlySet<T> if the cast was successful, or
nullotherwise.
Returns
- bool
trueif the cast was successful; otherwise,false.
Type Parameters
TThe type of elements in the collection.
TryAsSet<T>(IEnumerable<T>, out ISet<T>?)
Attempts to cast an IEnumerable<T> to an ISet<T>.
public static bool TryAsSet<T>(this IEnumerable<T> enumerable, out ISet<T>? set)
Parameters
enumerableIEnumerable<T>The enumerable to attempt to cast.
setISet<T>When this method returns, contains the resulting ISet<T> if the cast was successful, or
nullotherwise.
Returns
- bool
trueif the cast was successful; otherwise,false.
Type Parameters
TThe type of elements in the collection.