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
listT[]The array to check.
listArgNamestringThe name of the argument.
Returns
- T[]
The original array if it is not empty.
Type Parameters
TThe element type of the array.
Exceptions
- InvalidOperationException
listis 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
Returns
- IList<T>
The original list if it is not empty.
Type Parameters
TThe element type of the list.
Exceptions
- InvalidOperationException
listis empty.