We can Insert item in List collection at any specified Location or Position Index
With the help of Insert static method of List Collection,we can insert any item.
For Example:-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
System.Collections.Generic.List<string> names = new System.Collections.Generic.List<string>();
names.Add("Vishal "); //Output Would be:: Vishal
names.Add("Neeraj"); //Output Would be:: Vishal,Neeraj
names.Insert(1, "Kumar "); //Output Would be:: Vishal,Kumar,Neeraj
names.Insert(2, "Pune "); //Output Would be:: Vishal,Kumar,Pune,Neeraj
foreach (string name in names)
{
Response.Write(name);
}
}
}