TEnumerable.DefaultIfEmpty<T> Method

Overloads

DefaultIfEmpty<T>(IEnumerable<T>)

Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.

DefaultIfEmpty<T>(IEnumerable<T>, T)

Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.

DefaultIfEmpty<T>(IEnumerable<T>)

Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.

Delphi
class function DefaultIfEmpty<T>(const source: IEnumerable<T>): IEnumerable<T>

Type Parameters

T

The type of the elements of source .

Parameters

source
IEnumerable<T>

The sequence to return a default value for if it is empty.

Returns

IEnumerable<T>

A sequence that contains Default(T) if source is empty; otherwise, source .

Exceptions

source is nil .

DefaultIfEmpty<T>(IEnumerable<T>, T)

Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.

Delphi
class function DefaultIfEmpty<T>(const source: IEnumerable<T>; const defaultValue: T): IEnumerable<T>

Type Parameters

T

The type of the elements of source .

Parameters

source
IEnumerable<T>

The sequence to return a default value for if it is empty.

defaultValue
T

The value to return if the sequence is empty.

Returns

IEnumerable<T>

A sequence that contains defaultValue if source is empty; otherwise, source .

Exceptions

source is nil .