ListExtensions Class
Provides extension methods for the types System.Collections.IList and System.Collections.Generic.IList<T>.
public static class ListExtensions
- Inheritance:
- System.Object Object
Methods
AddRange<T>(IList<T>, IEnumerable<T>)
Adds the elements of the specified collection to the end of the list.
public static void AddRange<T>(this IList<T> list, IEnumerable<T> collection)
- Type Parameters:
-
T
-The type of elements in the list.
Parameter | Type | Description |
---|---|---|
list | System.Collections.Generic.IList<T> | The list to which the items should be added. |
collection | System.Collections.Generic.IEnumerable<T> | The collection whose elements should be added to the end of the list. The collection itself cannot be null, but it can contain elements that are null, if type |
InsertRange<T>(IList<T>, Int32, IEnumerable<T>)
Inserts the elements of a collection into the list at the specified index.
public static void InsertRange<T>(this IList<T> list, int index, IEnumerable<T> collection)
- Type Parameters:
-
T
-The type of elements in the list.
Parameter | Type | Description |
---|---|---|
list | System.Collections.Generic.IList<T> | The list to which the items should be inserted. |
index | System.Int32 | The zero-based index at which the new elements should be inserted.. |
collection | System.Collections.Generic.IEnumerable<T> | The collection whose elements should be inserted into the list. The collection itself cannot be null, but it can contain elements that are null, if type |
RemoveAll<T>(IList<T>, Predicate<T>)
Removes all the elements that match the conditions defined by the specified predicate.
public static int RemoveAll<T>(this IList<T> list, Predicate<T> match)
- Type Parameters:
-
T
-The type of elements in the list.
Parameter | Type | Description |
---|---|---|
list | System.Collections.Generic.IList<T> | The list from with the items should be removed. |
match | System.Predicate<T> | The System.Predicate<T> delegate that defines the conditions of the elements to remove. |
Returns
- System.Int32:
The number of elements removed from the System.Collections.Generic.IList<T>.
Inherited Members
- System.Object.ToString()
- System.Object.Equals(System.Object)
- System.Object.Equals(System.Object, System.Object)
- System.Object.ReferenceEquals(System.Object, System.Object)
- System.Object.GetHashCode()
- System.Object.GetType()
- System.Object.MemberwiseClone()