 | CollectionExtensions.ToArray<TSource, TTarget> Method |
Creates an array from a
ICollection<T>.
This method is faster than using Enumerable.Select(selector).ToArray() because the size of the target array is known in advance.
Namespace: TomsToolbox.EssentialsAssembly: TomsToolbox.Essentials (in TomsToolbox.Essentials.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntaxpublic 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 ICollection<TSource>
- A System.Collections.Generic.ICollection{TSource} to create an array from.
- selector Func<TSource, 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
ICollection<TSource>. 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