Class IListExtensions
- Namespace
- SunamoExtensions
- Assembly
- SunamoExtensions.dll
Extension methods for IList and IEnumerable types
public static class IListExtensions
- Inheritance
-
IListExtensions
- Inherited Members
Methods
Count(IEnumerable)
Counts the number of elements in the enumerable
public static int Count(this IEnumerable enumerable)
Parameters
enumerableIEnumerableEnumerable to count
Returns
- int
Number of elements
Count2<T>(IList<T>)
Counts elements in the list (renamed to avoid conflict with LINQ Count)
public static int Count2<T>(this IList<T> list)
Parameters
listIList<T>List to count
Returns
- int
Number of elements
Type Parameters
TType of elements in the list
Count3(IList)
Counts elements in non-generic list (renamed to avoid ambiguity)
public static int Count3(this IList list)
Parameters
listIListList to count
Returns
- int
Number of elements
DumpAsString<T>(IList<T>, string, object)
Dumps the list as a string representation
public static string DumpAsString<T>(this IList<T> list, string operation, object args)
Parameters
Returns
- string
String representation
Type Parameters
TType of elements in the list
Exceptions
- Exception
This method is not implemented
First2(IList)
Returns the first element or null (renamed to avoid conflict with LINQ First)
public static object? First2(this IList list)
Parameters
listIListList to get first element from
Returns
- object
First element or null
FirstOrNull(IEnumerable)
Returns the first element or null if the enumerable is empty
public static object? FirstOrNull(this IEnumerable enumerable)
Parameters
enumerableIEnumerableEnumerable to get first element from
Returns
- object
First element or null
Length2<T>(IList<T>)
Returns the length of the list
public static int Length2<T>(this IList<T> list)
Parameters
listIList<T>List to get length of
Returns
- int
Number of elements
Type Parameters
TType of elements in the list
RemoveAt<T>(IList<T>, int)
Removes element at specified index (creates new list)
public static IList<T> RemoveAt<T>(this IList<T> list, int index)
Parameters
Returns
- IList<T>
New list with element removed
Type Parameters
TType of elements in the list
RemoveLast<T>(IList<T>)
Removes the last element from the list
public static List<T> RemoveLast<T>(this IList<T> list)
Parameters
listIList<T>List to modify
Returns
- List<T>
Modified list
Type Parameters
TType of elements in the list
SortAsc<T>(List<T>)
Sorts the list in ascending order
public static void SortAsc<T>(this List<T> list)
Parameters
listList<T>List to sort
Type Parameters
TType of elements in the list
Swap<T>(IList<T>, int, int)
Swaps two elements in the list
public static void Swap<T>(this IList<T> list, int firstIndex, int secondIndex)
Parameters
listIList<T>List to modify
firstIndexintIndex of first element
secondIndexintIndex of second element
Type Parameters
TType of elements in the list
TakeLast<T>(IList<T>, int)
Takes the last N elements from the list
public static IList<T> TakeLast<T>(this IList<T> source, int count)
Parameters
Returns
- IList<T>
List containing the last N elements
Type Parameters
TType of elements in the list
Where2<TSource>(IList<TSource>, Func<TSource, bool>)
Filters elements based on a predicate
public static IList<TSource> Where2<TSource>(this IList<TSource> source, Func<TSource, bool> predicate)
Parameters
Returns
- IList<TSource>
Filtered list
Type Parameters
TSourceType of elements in the list
WhereNonGeneric(IList, Func<object, bool>)
Filters non-generic enumerable based on a predicate
public static List<object> WhereNonGeneric(this IList list, Func<object, bool> predicate)