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); }
/// <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()); } }
/// <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(); } }
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; }