Click or drag to resize

MoreEnumerableBacksertT Method

Inserts the elements of a sequence into another sequence at a specified index from the tail of the sequence, where zero always represents the last position, one represents the second-last element, two represents the third-last element and so on.

Namespace:  MoreLinq
Assembly:  MoreLinq (in MoreLinq.dll) Version: 3.2.0+5205ea241d72b079436060d330cd5c2eae7cdcdf
Syntax
public static IEnumerable<T> Backsert<T>(
	this IEnumerable<T> first,
	IEnumerable<T> second,
	int index
)

Parameters

first
Type: System.Collections.GenericIEnumerableT
The source sequence.
second
Type: System.Collections.GenericIEnumerableT
The sequence that will be inserted.
index
Type: SystemInt32
The zero-based index from the end of first where elements from second should be inserted. second.

Type Parameters

T
Type of elements in all sequences.

Return Value

Type: IEnumerableT
A sequence that contains the elements of first plus the elements of second inserted at the given index from the end of first.

Usage Note

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).
Exceptions
ExceptionCondition
ArgumentNullExceptionfirst is null.
ArgumentNullExceptionsecond is null.
ArgumentOutOfRangeException Thrown if index is negative.
ArgumentOutOfRangeException Thrown lazily if index is greater than the length of first. The validation occurs when the resulting sequence is iterated.
Remarks
This method uses deferred execution and streams its results.
See Also