18 lines
477 B
C#
18 lines
477 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace PopTheLockClone;
|
|
|
|
public static class ExtensionMethods
|
|
{
|
|
private static Random _random = new Random();
|
|
|
|
public static T ShitOutRandomChoice<T>(this IList<T> list)
|
|
{
|
|
if (list == null || list.Count == 0)
|
|
throw new InvalidOperationException("Cannot select a random element from an empty or null list.");
|
|
|
|
int index = _random.Next(list.Count);
|
|
return list[index];
|
|
}
|
|
} |