Class EnumerableExtensions
Provides extension methods for the IEnumerable<T> interface.
Namespace: Celestial.UIToolkit.Extensions
Assembly: Celestial.UIToolkit.Core.dll
Syntax
public static class EnumerableExtensions
Methods
| Improve this Doc View SourceAddRange<T>(ICollection<T>, IEnumerable<T>)
Adds the specified sequence to the collection
.
Declaration
public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
ICollection<T> | collection | The collection. |
IEnumerable<T> | items | The items to be added to the collection. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the collection. |
ElementAfter<T>(IEnumerable<T>, Int32)
Returns the element after the specified index
.
Declaration
public static T ElementAfter<T>(this IEnumerable<T> enumerable, int index)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | enumerable | The enumerable. |
Int32 | index | The index which will be used to find the next element. |
Returns
Type | Description |
---|---|
T | The element after the element at the specified |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the enumerable. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | |
ArgumentOutOfRangeException | Thrown if |
ElementAfterOrDefault<T>(IEnumerable<T>, Int32)
Returns the element after the specified index
or a default value, if the element at the specified index
is the last element in the sequence.
Declaration
public static T ElementAfterOrDefault<T>(this IEnumerable<T> enumerable, int index)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | enumerable | The enumerable. |
Int32 | index | The index which will be used to find the next element. |
Returns
Type | Description |
---|---|
T | The element after the element at the specified |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the enumerable. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | |
ArgumentOutOfRangeException | Thrown if |
ElementBefore<T>(IEnumerable<T>, Int32)
Returns the element which comes before the specified index
.
Declaration
public static T ElementBefore<T>(this IEnumerable<T> enumerable, int index)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | enumerable | The enumerable. |
Int32 | index | The index which will be used to find the previous element. |
Returns
Type | Description |
---|---|
T | The element which comes before the element at the specified |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the enumerable. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | |
ArgumentOutOfRangeException | Thrown if |
ElementBeforeOrDefault<T>(IEnumerable<T>, Int32)
Returns the element which comes before the specified index
or a default value, if the element at the specified index
is the first element in the sequence.
Declaration
public static T ElementBeforeOrDefault<T>(this IEnumerable<T> enumerable, int index)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | enumerable | The enumerable. |
Int32 | index | The index which will be used to find the previous element. |
Returns
Type | Description |
---|---|
T | The element which comes before the element at the specified |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the enumerable. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | |
ArgumentOutOfRangeException | Thrown if |
IndexOf<T>(IEnumerable<T>, T)
Returns the index of the specified value
in the sequence.
Declaration
public static int IndexOf<T>(this IEnumerable<T> enumerable, T value)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | enumerable | The enumerable. |
T | value | The value to be found. |
Returns
Type | Description |
---|---|
Int32 | The index of the found element; -1 if nothing was found. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the sequence. |
RemoveAll<T>(IList<T>, Func<T, Boolean>)
Removes all elements from the list (in place, the input list will be changed)
which satisfy the given predicate
.
Declaration
public static IList<T> RemoveAll<T>(this IList<T> list, Func<T, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | The list. |
Func<T, Boolean> | predicate | A predicate to be fulfilled for an item to be removed. |
Returns
Type | Description |
---|---|
IList<T> | The same |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the list. |