PopAny() public méthode

Selects a random item from the list and removes it.
public PopAny ( ) : object
Résultat object
Exemple #1
0
        public Array ToShuffledArray(Type elementType)
        {
            List  copy   = new List(ToArray());
            Array target = Array.CreateInstance(elementType, copy.Count);

            for (int i = 0; i < target.Length; ++i)
            {
                target.SetValue(copy.PopAny(), i);
            }
            return(target);
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 public Array Choose(int count)
 {
     if (_list.Count > count)
     {
         List     copy  = new List(_list);
         object[] items = new object[count];
         for (int i = 0; i < count; ++i)
         {
             items[i] = copy.PopAny();
         }
         return(items);
     }
     else
     {
         return(ToShuffledArray());
     }
 }
Exemple #3
0
		/// <summary>
		/// 
		/// </summary>
		public Array Choose(int count)
		{
			if (_list.Count > count)
			{
				List copy = new List(_list);
				object[] items = new object[count];
				for (int i=0; i<count; ++i)
				{
					items[i] = copy.PopAny();
				}
				return items;
			}
			else
			{
				return ToShuffledArray();
			}
		}
Exemple #4
0
		public Array ToShuffledArray(Type elementType)
		{
			List copy = new List(ToArray());
			Array target = Array.CreateInstance(elementType, copy.Count);
			for (int i=0; i<target.Length; ++i)
			{
				target.SetValue(copy.PopAny(), i);
			}
			return target;
		}