Convert List to array in CSharp

Description

The following code shows how to convert List to array.

Example


/*from w w w.j a  va  2s  . co m*/
using System;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        string[] input = { "A", "B", "C" };

        List<string> myData = new List<string>(input);
        string[] output = myData.GetRange(2, 3).ToArray();

        Console.WriteLine();
        foreach( string myD in output )
        {
            Console.WriteLine(myD);
        }
    }
}




















Home »
  C# Tutorial »
    Collections »




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