コード例 #1
0
        public static T GetRandomElementFromList <T>(List <T> theList)
        {
            T local2;

            if (!ReferenceEquals(theList, null))
            {
                local2 = theList[CachedRandom.Next(theList.Count)];
            }
            else
            {
                local2 = default(T);
            }
            return(local2);
        }
コード例 #2
0
        public static T GetRandomElementFromArray <T>(T[] theArray)
        {
            T local2;

            if (theArray != null)
            {
                local2 = theArray[CachedRandom.Next(theArray.Length)];
            }
            else
            {
                local2 = default(T);
            }
            return(local2);
        }
コード例 #3
0
 public static float RandomHeading() =>
 (((float)CachedRandom.NextDouble()) * 360f);
コード例 #4
0
 public static bool RandomBool() =>
 (CachedRandom.Next(0, 2) == 0);