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) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax
public static TTarget[] ToArray<TSource, TTarget>(
	this ICollection<TSource> items,
	Func<TSource, TTarget> selector
)

Parameters

items  ICollectionTSource
A System.Collections.Generic.ICollection{TSource} to create an array from.
selector  FuncTSource, 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

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