Click or drag to resize

CollectionExtensions Class

Extensions methods to ease dealing with collections.
Inheritance Hierarchy
SystemObject
  TomsToolbox.EssentialsCollectionExtensions

Namespace: TomsToolbox.Essentials
Assembly: TomsToolbox.Essentials (in TomsToolbox.Essentials.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax
public static class CollectionExtensions

The CollectionExtensions type exposes the following members.

Methods
 NameDescription
Public Extension MethodAddRange(IList, IEnumerable) Adds the elements of the specified collection to the end of the list.
Public Extension MethodAddRangeT(ICollectionT, IEnumerableT) Adds the elements of the specified collection to the end of the list.
Public Extension MethodAddRangeT(ICollectionT, T, T, T) Adds the elements of the specified collection to the end of the list.
Public Extension MethodContainsAny(String, Char) Shortcut to test if any of the given characters is contained in the specified string.
Public Extension MethodContainsAnyT(IEnumerableT, T) Shortcut to test if any of the given items are contained in the specified object.
Public Extension MethodContainsAnyT(IEnumerableT, IEqualityComparerT, T) Shortcut to test if any of the given items are contained in the specified object.
Public Extension MethodFindIndexT Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire IEnumerableT.
Public Extension MethodForceValueTKey, TValue(IDictionaryTKey, TValue, TKey, TValue) Gets the value associated with the specified key from the dictionary, or creates a new entry if the dictionary does not contain a value associated with the key.
Public Extension MethodForceValueTKey, TValue(IDictionaryTKey, TValue, TKey, FuncTKey, TValue) Gets the value associated with the specified key from the dictionary, or creates a new entry if the dictionary does not contain a value associated with the key.
Public Extension MethodForEachT(IEnumerableT, ActionT, Int32) Performs the specified action on each element of the collection, providing also the index of the item.
Public Extension MethodForEachT(IEnumerableT, ActionT) Performs the specified action on each element of the collection.
Public Extension MethodGetValueOrDefaultTKey, TValue(DictionaryTKey, TValue, TKey) Gets the value from the dictionary, or the default value of TValue if no item with the specified key exists.
Public Extension MethodGetValueOrDefaultTKey, TValue(IDictionaryTKey, TValue, TKey) Gets the value from the dictionary, or the default value of TValue if no item with the specified key exists.
Public Extension MethodGetValueOrDefaultTKey, TValue(IReadOnlyDictionaryTKey, TValue, TKey) Gets the value from the dictionary, or the default value of TValue if no item with the specified key exists.
Public Extension MethodGetValueOrDefaultTKey, TValue(DictionaryTKey, TValue, TKey, TValue) Gets the value from the dictionary, or the default value if no item with the specified key exists.
Public Extension MethodGetValueOrDefaultTKey, TValue(IDictionaryTKey, TValue, TKey, TValue) Gets the value from the dictionary, or the default value if no item with the specified key exists.
Public Extension MethodGetValueOrDefaultTKey, TValue(IReadOnlyDictionaryTKey, TValue, TKey, TValue) Gets the value from the dictionary, or the default value if no item with the specified key exists.
Public Extension MethodIndexOfT(IEnumerableT, T) Searches for the specified object and returns the zero-based index of the first occurrence within all items.
Public Extension MethodIndexOfT(IEnumerableT, T, IEqualityComparerT) Searches for the specified object and returns the zero-based index of the first occurrence within all items.
Public Extension MethodRemoveRange(IList, IEnumerable) Removes a range of elements from the list.
Public Extension MethodRemoveRangeT(ICollectionT, IEnumerableT) Removes a range of elements from the list.
Public Extension MethodRemoveWhereT Removes the range of elements from the list that fulfill the condition.
Public methodStatic memberRepeatT Repeats the specified source multiple times.
Public Extension MethodSynchronizeWithT(ICollectionT, ICollectionT) Synchronizes the items of the source list with the items of the target list. The order of the items is ignored.
Public Extension MethodSynchronizeWithT(ICollectionT, ICollectionT, IEqualityComparerT) Synchronizes the items of the source list with the items of the target list. The order of the items is ignored.
Public Extension MethodTakeT Retrieves the specified number of items from the source. If source contains less items than specified, all available items are returned.
Public Extension MethodToArrayTSource, TTarget Creates an array from a ICollectionT. This method is faster than using Enumerable.Select(selector).ToArray() because the size of the target array is known in advance.
Public Extension MethodToDictionaryTKey, TValue(IEnumerableKeyValuePairTKey, TValue) Creates a Dictionary{TKey, TValue} from an IEnumerable{KeyValuePair{TKey, TValue}}.
Public Extension MethodToDictionaryTKey, TValue(IEnumerableKeyValuePairTKey, TValue, IEqualityComparerTKey) Creates a Dictionary{TKey, TValue} from an IEnumerable{KeyValuePair{TKey, TValue}}.
Public Extension MethodTransposeTKey, TValue Transposes the specified items, i.e. exchanges key and value.
Public Extension MethodTryAddRangeT Adds the elements of the specified collection to the end of the list, but ignores all ArgumentException, e.g. when trying to add duplicate keys to a dictionary.
Top
See Also