Click or drag to resize

CollectionExtensionsTakeT Method

Retrieves the specified number of items from the source. If source contains less items than specified, all available items are returned.

Namespace:  TomsToolbox.Essentials
Assembly:  TomsToolbox.Essentials (in TomsToolbox.Essentials.dll)
Syntax
public static IList<T> Take<T>(
	this IEnumerator<T> source,
	int numberOfItems
)

Parameters

source
Type: System.Collections.GenericIEnumeratorT
The source enumerator to retrieve the items from. The enumerator position will be incremented by the number of items returned.
numberOfItems
Type: SystemInt32
The number of items to retrieve.

Type Parameters

T
The type of elements in the list.

Return Value

Type: IListT
A list that contains up to n items from the source.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumeratorT. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also