Table of Contents

Class EnumerableEx

Namespace
DynamicData.Kernel
Assembly
DynamicData.dll

Enumerable extensions.

public static class EnumerableEx
Inheritance
EnumerableEx

Methods

AsArray<T>(IEnumerable<T>)

Casts the enumerable to an array if it is already an array. Otherwise call ToArray.

public static T[] AsArray<T>(this IEnumerable<T> source)

Parameters

source IEnumerable<T>

The source.

Returns

T[]

The array of items.

Type Parameters

T

The type of the item.

AsList<T>(IEnumerable<T>)

Casts the enumerable to a List if it is already a List. Otherwise call ToList.

public static List<T> AsList<T>(this IEnumerable<T> source)

Parameters

source IEnumerable<T>

The source.

Returns

List<T>

The list.

Type Parameters

T

The type of the item.

Duplicates<T, TValue>(IEnumerable<T>, Func<T, TValue>)

Returns any duplicated values from the source.

public static IEnumerable<T> Duplicates<T, TValue>(this IEnumerable<T> source, Func<T, TValue> valueSelector)

Parameters

source IEnumerable<T>

The source.

valueSelector Func<T, TValue>

The value selector.

Returns

IEnumerable<T>

The enumerable of items.

Type Parameters

T

The type of the item.

TValue

The type of the value.

IndexOfMany<T>(IEnumerable<T>, IEnumerable<T>)

Finds the index of many items as specified in the secondary enumerable.

public static IEnumerable<ItemWithIndex<T>> IndexOfMany<T>(this IEnumerable<T> source, IEnumerable<T> itemsToFind)

Parameters

source IEnumerable<T>

The source.

itemsToFind IEnumerable<T>

The items to find in the source enumerable.

Returns

IEnumerable<ItemWithIndex<T>>

A result as specified by the result selector.

Type Parameters

T

The type of the item.

IndexOfMany<TObject, TResult>(IEnumerable<TObject>, IEnumerable<TObject>, Func<TObject, int, TResult>)

Finds the index of many items as specified in the secondary enumerable.

public static IEnumerable<TResult> IndexOfMany<TObject, TResult>(this IEnumerable<TObject> source, IEnumerable<TObject> itemsToFind, Func<TObject, int, TResult> resultSelector)

Parameters

source IEnumerable<TObject>

The source.

itemsToFind IEnumerable<TObject>

The items to find.

resultSelector Func<TObject, int, TResult>

The result selector.

Returns

IEnumerable<TResult>

A result as specified by the result selector.

Type Parameters

TObject

The type of the object.

TResult

The type of the result.