Insert an element into the List at the specified index in CSharp
Description
The following code shows how to insert an element into the List at the specified index.
Example
using System;//from w w w . ja v a2 s.c o m
using System.Collections;
using System.Collections.Generic;
class Sample
{
public static void Main()
{
List<string> words = new List<string>();
words.Insert(0, "A"); // Insert at start
foreach (string s in words) {
Console.WriteLine (s);
}
}
}
The code above generates the following result.