public new ChoNotNullableArrayList GetRange(int index, int count) { if ((index < 0) || (count < 0)) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", "ArgumentOutOfRange_NeedNonNegNum"); } if ((this.Count - index) < count) { throw new ArgumentException("Argument_InvalidOffLen"); } return(new ChoNotNullableArrayList(ChoArray.SubArray(this, index, count))); }
public static ICollection Split(ICollection srcArray, int chunkSize) { if (chunkSize == 0) { throw new ApplicationException("ChunkSize should be greater than zero."); } ArrayList subArrays = new ArrayList(); if (srcArray == null || srcArray.Count <= chunkSize) { subArrays.Add(srcArray); } else { int index = 0; object[] subArray = new object[chunkSize]; foreach (object arrayItem in srcArray) { if (index == chunkSize) { subArrays.Add(ChoArray.ConvertTo(subArray, subArray[0].GetType())); index = 0; subArray = new object[chunkSize]; } subArray[index++] = arrayItem; } if (subArray.Length > 0) { subArray = ChoArray.Trim(subArray) as object[]; subArrays.Add(ChoArray.ConvertTo(subArray, subArray[0].GetType())); } } return(subArrays.ToArray()); }