Table of Contents

Method ThrowIfEmpty

Namespace
Gamelogic.Extensions
Assembly
Gamelogic.Extensions.dll

ThrowIfEmpty<T>(T[], string)

Throws an InvalidOperationException if the array is empty.

public static T[] ThrowIfEmpty<T>(this T[] list, string listArgName = null)

Parameters

list T[]

The array to check.

listArgName string

The name of the argument.

Returns

T[]

The original array if it is not empty.

Type Parameters

T

The element type of the array.

Exceptions

InvalidOperationException

list is empty.

ThrowIfEmpty<T>(IList<T>, string)

Throws an InvalidOperationException if the list is empty.

public static IList<T> ThrowIfEmpty<T>(this IList<T> list, string listArgName = null)

Parameters

list IList<T>

The list to check.

listArgName string

The name of the argument.

Returns

IList<T>

The original list if it is not empty.

Type Parameters

T

The element type of the list.

Exceptions

InvalidOperationException

list is empty.