C# Collection Insert
Description
inserts an element into the Collection at the specified index.
Syntax
Collection.Insert
has the following syntax.
public void Insert(
int index,
T item
)
Parameters
Collection.Insert
has the following 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.
Example
using System;// ww w. j av a 2 s. co m
using System.Collections.Generic;
using System.Collections.ObjectModel;
public class Demo
{
public static void Main()
{
Collection<string> myData = new Collection<string>();
myData.Add("A");
myData.Add("B");
myData.Add("C");
myData.Add("D");
myData.Insert(0,"D");
}
}