| 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
)
<ExtensionAttribute>
Public Shared Function ToArray(Of TSource, TTarget) (
items As ICollection(Of TSource),
selector As Func(Of TSource, TTarget)
) As TTarget()
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:
TTargetAn 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