Insert a collection the List at the specified index in CSharp

Description

The following code shows how to insert a collection the List at the specified index.

Example


using System;/*  w ww . j  a  va2 s .  c o  m*/
using System.Collections;
using System.Collections.Generic;

class Sample
{
    public static void Main()
    {
        List<string> words = new List<string>();  

        words.InsertRange(0, new[] { "E", "F" });

        
        foreach (string s in words) {
            Console.WriteLine (s);
        }
    }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary