using System; using System.Collections; using System.Collections.Generic; using
System.Linq; namespace Core.Util { /// <summary> /// Random Random number helper class /// </summary>
public static class RandomHelper { private static Random _random { get; } = new
Random(); /// <summary> /// Next random number /// </summary> /// <param
name="minValue"> minimum value </param> /// <param name="maxValue"> Maximum </param> ///
<returns></returns> public static int Next(int minValue, int maxValue) { return
_random.Next(minValue, maxValue); } /// <summary> /// Next random value /// </summary> ///
<typeparam name="T"> Value type </typeparam> /// <param name="source"> A collection of values </param> ///
<returns></returns> public static T Next<T>(IEnumerable<T> source) { return
source.ToList()[Next(0, source.Count())]; } } }
Technology