Class EnumerableExtensions
Extension methods for
Inheritance
Namespace: X10D.Collections
Assembly: X10D.dll
Syntax
public static class EnumerableExtensions : object
Methods
| Improve this Doc View SourceCountWhereNot<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)
Returns a number that represents how many elements in the specified sequence do not satisfy a condition.
Declaration
public static int CountWhereNot<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | A sequence that contains elements to be tested and counted. |
Func<TSource, System.Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
System.Int32 | A number that represents how many elements in the sequence do not satisfy the condition in the
|
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
DisposeAll<T>(IEnumerable<T>)
Calls
Declaration
public static void DisposeAll<T>(this IEnumerable<T> source)
where T : IDisposable
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The enumerable collection whose elements to dispose. |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in |
See Also
| Improve this Doc View SourceDisposeAllAsync<T>(IEnumerable<T>)
Asynchronously calls
Declaration
public static Task DisposeAllAsync<T>(this IEnumerable<T> source)
where T : IAsyncDisposable
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The enumerable collection whose elements to dispose. |
Returns
Type | Description |
---|---|
Task |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in |
See Also
| Improve this Doc View SourceFirstWhereNot<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)
Returns the first element in a sequence that does not satisfy a specified condition.
Declaration
public static TSource FirstWhereNot<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | An |
Func<TSource, System.Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | The first element in the sequence that fails the test in the specified predicate function. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in |
FirstWhereNotOrDefault<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)
Returns the first element in a sequence that does not satisfy a specified condition.
Declaration
public static TSource FirstWhereNotOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | An |
Func<TSource, System.Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | langword_csharp_default(TSource) if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in |
For<T>(IEnumerable<T>, Action<Int32, T>)
Performs the specified action on each element of the
Declaration
public static void For<T>(this IEnumerable<T> source, Action<int, T> action)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The |
Action<System.Int32, T> | action | The |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in |
ForEach<T>(IEnumerable<T>, Action<T>)
Performs the specified action on each element of the
Declaration
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The |
Action<T> | action | The |
Type Parameters
Name | Description |
---|---|
T | The type of the elements in |
LastWhereNot<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)
Returns the last element in a sequence that does not satisfy a specified condition.
Declaration
public static TSource LastWhereNot<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | An |
Func<TSource, System.Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | The last element in the sequence that fails the test in the specified predicate function. |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in |
LastWhereNotOrDefault<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)
Returns the last element in a sequence that does not satisfy a specified condition.
Declaration
public static TSource LastWhereNotOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | An |
Func<TSource, System.Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
TSource | langword_csharp_default(TSource) if |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements in |
Shuffled<T>(IEnumerable<T>, Nullable<Random>)
Reorganizes the elements in an enumerable by implementing a Fisher-Yates shuffle, and returns th shuffled result.
Declaration
public static IReadOnlyCollection<T> Shuffled<T>(this IEnumerable<T> source, Random? random = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | source | The |
System.Nullable<Random> | random | Optional. The |
Returns
Type | Description |
---|---|
IReadOnlyCollection<T> | The shuffled collection. |
Type Parameters
Name | Description |
---|---|
T | The element type. |
WhereNot<TSource>(IEnumerable<TSource>, Func<TSource, Boolean>)
Filters a sequence of values based on a predicate, such that all elements in the result do not match the predicate.
Declaration
public static IEnumerable<TSource> WhereNot<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | An |
Func<TSource, System.Boolean> | predicate | A function to test each element for a condition. |
Returns
Type | Description |
---|---|
IEnumerable<TSource> | An |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |
WhereNotNull<TSource>(IEnumerable<TSource>)
Filters a sequence of values by omitting elements that are null (langword_csharp_Nothing in Visual Basic).
Declaration
public static IEnumerable<TSource> WhereNotNull<TSource>(this IEnumerable<TSource> source)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TSource> | source | An |
Returns
Type | Description |
---|---|
IEnumerable<TSource> | An |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of |