Collection<T>.Insert(Int32, T) method is used to insert an element into the Collection<
T> at the specified index.
Syntax:
public void Insert (int index, T item);
Parameters:
index : The zero-based index at which item should be inserted.
item : The object to insert. The value can be null for reference types.
Exception: This method will give
ArgumentOutOfRangeException if
index is less than zero
OR index is greater than Count.
Below given are some examples to understand the implementation in a better way:
Example 1:
Output:
Count : 5
A
B
C
D
E
Count : 6
A
B
GFG
C
D
E
Example 2: