C# List List(IEnumerable)
Description
List
initializes
a new instance of the List
Syntax
public List(
IEnumerable<T> collection
)
Parameters
collection
- The collection whose elements are copied to the new list.
Example
The following example demonstrates the List constructor.
/*from ww w .java2 s .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);
Console.WriteLine("\nCapacity: {0}", myData.Capacity);
}
}
The code above generates the following result.