ToArrayByIndexExtensionToArrayByIndexT, TResult(IEnumerableT, Int32, FuncT, Int32, FuncT, TResult) Method
Creates an array of user-specified length from an
IEnumerableT where a function is used to determine
the index at which an element will be placed in the array. The
elements are projected into the array via an additional function.
Namespace: MoreLinq.ExtensionsAssembly: MoreLinq (in MoreLinq.dll) Version: 3.4.0+b99a6a8cc504caf2d48372fe54a2f8116c59cd0c
public static TResult[] ToArrayByIndex<T, TResult>(
this IEnumerable<T> source,
int length,
Func<T, int> indexSelector,
Func<T, TResult> resultSelector
)
<ExtensionAttribute>
Public Shared Function ToArrayByIndex(Of T, TResult) (
source As IEnumerable(Of T),
length As Integer,
indexSelector As Func(Of T, Integer),
resultSelector As Func(Of T, TResult)
) As TResult()
public:
[ExtensionAttribute]
generic<typename T, typename TResult>
static array<TResult>^ ToArrayByIndex(
IEnumerable<T>^ source,
int length,
Func<T, int>^ indexSelector,
Func<T, TResult>^ resultSelector
)
[<ExtensionAttribute>]
static member ToArrayByIndex :
source : IEnumerable<'T> *
length : int *
indexSelector : Func<'T, int> *
resultSelector : Func<'T, 'TResult> -> 'TResult[]
- source IEnumerableT
- The source sequence for the array.
- length Int32
- The (non-negative) length of the resulting array.
- indexSelector FuncT, Int32
-
A function that maps an element to its index.
- resultSelector FuncT, TResult
-
A function to project a source element into an element of the
resulting array.
- T
-
The type of the element in source.
- TResult
-
The type of the element in the resulting array.
TResult
An array of size
length that contains the
projected elements from the input sequence.
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. 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).
This method forces immediate query evaluation. It should not be
used on infinite sequences. If more than one element maps to the
same index then the latter element overwrites the former in the
resulting array.