You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
562 B
22 lines
562 B
namespace Kynareth;
|
|
|
|
public static class Extensions
|
|
{
|
|
public static T GetRandomEnumValue<T>() where T : Enum
|
|
=> (T) Enum.GetValues(typeof(T)).OfType<Enum>().OrderBy(_ => Guid.NewGuid()).FirstOrDefault();
|
|
|
|
public static IList<int> Range(int start, int stop, int step)
|
|
{
|
|
var list = new List<int>();
|
|
|
|
for (int i = start; i < stop; i += step) {
|
|
list.Add(i);
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
public static T[] Except<T>(this T[] array, T specificValue) where T : IComparable {
|
|
return array.Where<T>(val => val.CompareTo(specificValue) != 0).ToArray();
|
|
}
|
|
} |