Enumerable.Prepend(IEnumerable<TSource>, TSource) Method

Definition

Adds a value to the beginning of the sequence.

public static System.Collections.Generic.IEnumerable<TSource> Prepend<TSource> (this System.Collections.Generic.IEnumerable<TSource> source, TSource element);
Type Parameters
TSource

The type of the elements of source.

Parameters
source
IEnumerable<TSource>

A sequence of values.

element

The value to prepend to source.

Returns
IEnumerable<TSource>

A new sequence that begins with element.

Exceptions

source is null.

Applies to