Class ExtensionMethods
Provides common "extension" methods that are available in higher .NET Frameworks but not in the 2.0 Framework.
public static class ExtensionMethods
- Inheritance
-
ExtensionMethods
- Inherited Members
Methods
AddRange<T>(ICollection<T>, IEnumerable<T>)
Adds the items of the specified enumerable to the end of the collection.
public static void AddRange<T>(ICollection<T> collection, IEnumerable<T> items)
Parameters
collectionICollection<T>An ICollection<T> instance.
itemsIEnumerable<T>The items to add to the collection.
Type Parameters
TThe type of the items in the
collection.
Exceptions
- ArgumentNullException
collectionoritemsis anullreference.
ConvertAll<T, TOutput>(IEnumerable<T>, Converter<T, TOutput>)
Converts the items returned by enumerable to another type,
and returns a list containing the converted elements.
public static List<TOutput> ConvertAll<T, TOutput>(IEnumerable<T> enumerable, Converter<T, TOutput> converter)
Parameters
enumerableIEnumerable<T>An IEnumerable<T> instance.
converterConverter<T, TOutput>A delegate that converts each element to another type.
Returns
- List<TOutput>
A list containing the converted items.
Type Parameters
TThe type of the items returned by
enumerable.TOutputThe type of the converted items in the returned list.
ForEach<T>(IEnumerable<T>, Action<T>)
Performs the specified action on each item returned by enumerable.
public static void ForEach<T>(IEnumerable<T> enumerable, Action<T> action)
Parameters
enumerableIEnumerable<T>An IEnumerable<T> instance.
actionAction<T>The Action<T> delegate to perform on each item returned by
enumerable.
Type Parameters
TThe type of the items returned by
enumerable.
Exceptions
- ArgumentNullException
enumerableoractionis anullreference.
RemoveDuplicates<T, S>(ICollection<T>, MapDelegate<T, S>)
Removes duplicates from a list using the provided identity mapping function.
public static List<T> RemoveDuplicates<T, S>(ICollection<T> srcCollection, ExtensionMethods.MapDelegate<T, S> identFunc)
Parameters
srcCollectionICollection<T>The collection to remove the duplicates from.
identFuncExtensionMethods.MapDelegate<T, S>The identity mapping function to apply to the items in the collection.
Returns
- List<T>
A new list containing all elements from the source collection, without duplicates.
Type Parameters
TThe type of the items in the collection.
SThe type of the item identity.
SequenceEqual<T>(IList<T>, IList<T>)
Determines whether two lists are equal by comparing their elements.
public static bool SequenceEqual<T>(IList<T> a, IList<T> b)
Parameters
Returns
- bool
Trueif the two lists contain the same elements in the same order; otherwisefalse.
Type Parameters
TThe type of the items in the lists.
TrueForAll<T>(IEnumerable<T>, Predicate<T>)
Determines whether every item returned by enumerable matches the conditions
defined by the specified predicate.
public static bool TrueForAll<T>(IEnumerable<T> enumerable, Predicate<T> match)
Parameters
enumerableIEnumerable<T>An IEnumerable<T> instance.
matchPredicate<T>The Predicate<T> delegate that defines the conditions to check against the items.
Returns
- bool
trueif every item returned byenumerablematches the conditions defined by the specified predicate; otherwise,false. If the enumerable returns no items, the return value istrue.
Type Parameters
TThe type of the items returned by
enumerable.
Exceptions
- ArgumentNullException
enumerableormatchis anullreference.