Head

Returns the first element of the collection.

Parameters

Returns

IEnumerable<T> source

T

#### Exception

Type

When

InvalidOperationException

It is an empty collection.

Usage

Getting the first element

//IEnumerable<int> source = { 5, 8, 9, 10 }
int result = source.Head();

//result = 5

Last updated