Class IListExtensions
- Namespace
- Garyon.Extensions
- Assembly
- Garyon.dll
Provides extension methods for the IList<T> interface.
public static class IListExtensions
- Inheritance
-
IListExtensions
- Inherited Members
Methods
AddRange(IList, IEnumerable)
Adds a range of items to the given list.
public static void AddRange(this IList list, IEnumerable items)
Parameters
listIListThe IList on which to add the items.
itemsIEnumerableThe items to add to the list.
AddRangeAsync<T>(IList<T>, IAsyncEnumerable<IEnumerable<T>>)
Adds a range of elements from an IAsyncEnumerable<T> into the IList<T>.
public static Task AddRangeAsync<T>(this IList<T> list, IAsyncEnumerable<IEnumerable<T>> collection)
Parameters
listIList<T>The IList<T> to which to add the elements.
collectionIAsyncEnumerable<IEnumerable<T>>The IAsyncEnumerable<T> whose elements to add to the provided list.
Returns
Type Parameters
TThe type of the elements contained in the IList<T>.
AddRangeAsync<T>(IList<T>, IAsyncEnumerable<T>)
Adds a range of elements from an IAsyncEnumerable<T> into the IList<T>.
public static Task AddRangeAsync<T>(this IList<T> list, IAsyncEnumerable<T> collection)
Parameters
listIList<T>The IList<T> to which to add the elements.
collectionIAsyncEnumerable<T>The IAsyncEnumerable<T> whose elements to add to the provided list.
Returns
Type Parameters
TThe type of the elements contained in the IList<T>.
AtIndexOrDefaultReadOnly<T>(IReadOnlyList<T>, int)
public static T? AtIndexOrDefaultReadOnly<T>(this IReadOnlyList<T> source, int index)
Parameters
sourceIReadOnlyList<T>indexint
Returns
- T
Type Parameters
T
AtIndexOrDefault<T>(IList<T>, int)
public static T? AtIndexOrDefault<T>(this IList<T> source, int index)
Parameters
Returns
- T
Type Parameters
T
ClearSetRange(IList, IEnumerable)
Clears the entire list and sets its contents to the given range.
public static void ClearSetRange(this IList list, IEnumerable items)
Parameters
listIListThe IList to clear and whose items to set.
itemsIEnumerableThe items to set to the list.
Insert<T>(IList<T>, Index, T)
Inserts an element to the list at the specified index.
public static void Insert<T>(this IList<T> list, Index index, T element)
Parameters
listIList<T>The list to add an element to.
indexIndexThe index that the element will be located at after insertion.
elementTThe element to insert to the list.
Type Parameters
TThe type of the elements contained in the IList<T>.
Pop<T>(IList<T>)
Pops the last element from the list and returns it.
public static T Pop<T>(this IList<T> list)
Parameters
listIList<T>The list from which to pop the element.
Returns
- T
The popped element.
Type Parameters
TThe type of the elements in the list.
RemoveAtDecrement<T>(IList<T>, ref int)
Removes an element from the list at the specified index and decrements the provided index by reference.
public static void RemoveAtDecrement<T>(this IList<T> list, ref int index)
Parameters
listIList<T>The list from which to remove the element.
indexintA reference to the index that will be decremented after removing the element from the list.
Type Parameters
TThe type of the elements in the list.
RemoveAt<T>(IList<T>, Index)
Removes an element from the list at the specified index.
public static void RemoveAt<T>(this IList<T> list, Index index)
Parameters
listIList<T>The list to remove an element from.
indexIndexThe index of the element in the list to remove.
Type Parameters
TThe type of the elements contained in the IList<T>.
RemoveLast<T>(IList<T>)
Removes the last element from the provided list.
public static void RemoveLast<T>(this IList<T> list)
Parameters
listIList<T>The list to remove the last element from.
Type Parameters
TThe type of the elements contained in the IList<T>.
SingleOrDefaultReadOnly<T>(IReadOnlyList<T>)
public static T? SingleOrDefaultReadOnly<T>(this IReadOnlyList<T> source)
Parameters
sourceIReadOnlyList<T>
Returns
- T
Type Parameters
T
SingleOrDefaultSafe<T>(IList<T>)
public static T? SingleOrDefaultSafe<T>(this IList<T> source)
Parameters
sourceIList<T>
Returns
- T
Type Parameters
T
Swap<T>(IList<T>, Index, Index)
Swaps two elements in the IList<T>.
public static IList<T> Swap<T>(this IList<T> list, Index a, Index b)
Parameters
listIList<T>The IList<T> within which to swap two elements.
aIndexThe index of the first element to swap.
bIndexThe index of the second element to swap.
Returns
Type Parameters
TThe type of the elements contained in the IList<T>.
Swap<T>(IList<T>, int, int)
Swaps two elements in the IList<T>.
public static IList<T> Swap<T>(this IList<T> list, int a, int b)
Parameters
listIList<T>The IList<T> within which to swap two elements.
aintThe index of the first element to swap.
bintThe index of the second element to swap.
Returns
Type Parameters
TThe type of the elements contained in the IList<T>.
TryGetAtIndexReadOnly<T>(IReadOnlyList<T>, int, out T?)
public static bool TryGetAtIndexReadOnly<T>(this IReadOnlyList<T> source, int index, out T? value)
Parameters
sourceIReadOnlyList<T>indexintvalueT
Returns
Type Parameters
T
TryGetAtIndex<T>(IList<T>, int, out T?)
public static bool TryGetAtIndex<T>(this IList<T> source, int index, out T? value)
Parameters
Returns
Type Parameters
T