public virtual void InsertRange(int index, ICollection c)
{
if (c == null)
throw new ArgumentNullException(nameof(c), SR.ArgumentNull_Collection);
if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
//Contract.Ensures(Count == Contract.OldValue(Count) + c.Count);
Contract.EndContractBlock();
int count = c.Count;
if (count > 0)
{
EnsureCapacity(_size + count);
// shift existing items
if (index < _size)
{
Array.Copy(_items, index, _items, index + count, _size - index);
}
Object[] itemsToInsert = new Object[count];
c.CopyTo(itemsToInsert, 0);
itemsToInsert.CopyTo(_items, index);
_size += count;
_version++;
}
}