Click or drag to resize

CollectionExtensionsToArrayTSource, TTarget Method

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.

Namespace:  TomsToolbox.Essentials
Assembly:  TomsToolbox.Essentials (in TomsToolbox.Essentials.dll)
Syntax
public static TTarget[] ToArray<TSource, TTarget>(
	this ICollection<TSource> items,
	Func<TSource, TTarget> selector
)

Parameters

items
Type: System.Collections.GenericICollectionTSource
A System.Collections.Generic.ICollection{TSource} to create an array from.
selector
Type: SystemFuncTSource, TTarget
The selector to select the elements in the array.

Type Parameters

TSource
The type of the items in the source collection.
TTarget
The type of the items in the result collection.

Return Value

Type: TTarget
An array that contains the selected elements from the input sequence.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ICollectionTSource. 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