System.Runtime.CompilerServices.ReadOnlyCollectionBuilder.Insert C# (CSharp) Method

Insert() public method

Inserts an item to the ReadOnlyCollectionBuilder{T} at the specified index.
public Insert ( int index, item ) : void
index int The zero-based index at which item should be inserted.
item The object to insert into the .
return void
        public void Insert(int index, T item)
        {
            if (index > _size)
                throw new ArgumentOutOfRangeException(nameof(index));

            if (_size == _items.Length)
            {
                EnsureCapacity(_size + 1);
            }
            if (index < _size)
            {
                Array.Copy(_items, index, _items, index + 1, _size - index);
            }
            _items[index] = item;
            _size++;
            _version++;
        }