Table of Contents

Previous Method

Definition

Namespace
Cuemon.Extensions.Collections.Generic
Assemblies
Cuemon.Extensions.Collections.Generic.dll
Source
src/Cuemon.Extensions.Collections.Generic/ListExtensions.cs

Previous<T>(IList<T>, int)

Returns the previous element of list relative to index, or the first or last element of list if index is equal, greater or lower than Count.

public static T Previous<T>(this IList<T> list, int index)

Parameters

list IList<T>

The IList<T> to extend.

index int

The index of which to advance to the previous element from.

Returns

T

default(TSource) if index is equal, greater or lower than Count; otherwise the previous element of list relative to index.

Type Parameters

T

The type of elements in the IList<T>.

Exceptions

ArgumentNullException

list is null.

ArgumentOutOfRangeException

index is less than 0.