PopTheLockClone/ExtensionMethods.cs
Bobby Lucero c3323fb6dd Initial Commit
Didn't use git for a minute, oh well.
2025-06-05 00:32:29 -04:00

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];
}
}