Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: IEnumerable<T> InsertBetweenWithAnd<T>(this IEnumerable<T>, T, T)

Declaration

public static IEnumerable<T> InsertBetweenWithAnd<T>(
    this IEnumerable<T> source,
    T comma,
    T and
)

Summary

Inserts the comma item in between each element in the input collection except between the second-last and last, where it inserts and instead.

Generic type parameters

TThis type parameter is not documented.

Parameters

this IEnumerable<T>source The input collection.
Tcomma The element to insert between each consecutive pair of elements in the input collection except between the second-last and last.
Tand The element to insert between the second-last and last element of the input collection.

Returns

A collection containing the original collection with the extra element inserted. For example, new[] { "a", "b", "c" }.InsertBetweenWithAnd(", ", " and ") returns { "a", ", ", "b", " and ", "c" }.