Method Backsert
| Edit this pageBacksert<T>(IEnumerable<T>, IEnumerable<T>, int)
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.
Declaration
[Obsolete("Backsert has been replaced by Insert(second, Index index)")]
public static IEnumerable<T> Backsert<T>(this IEnumerable<T> first, IEnumerable<T> second, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<T> | first | The source sequence. |
| IEnumerable<T> | second | The sequence that will be inserted. |
| int | index | The zero-based index from the end of |
Returns
| Type | Description |
|---|---|
| IEnumerable<T> | A sequence that contains the elements of |
Type Parameters
| Name | Description |
|---|---|
| T | Type of elements in all sequences. |
Remarks
This operator uses deferred execution and streams its results.
Examples
Note
Backsert has been deprecated in favor of Insert. Please see here for documentation on the equivalent method.
The following code example demonstrates how to insert one sequence into another, using Backsert.
var first = Enumerable.Range(1, 5);
var second = Enumerable.Range(1, 5);
// Insert one sequence into another
var result = first
.Backsert(second, 2);
Console.WriteLine(string.Join(", ", result));
// This code produces the following output:
// 1, 2, 3, 1, 2, 3, 4, 5, 4, 5
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|
| ArgumentOutOfRangeException | Thrown lazily if |