C# Collection Constructor
Description
initializes a new instance of the Collection class that is empty.
Syntax
public Collection()
Example
Initializes a new instance of the Collection class that is empty.
using System;/* ww w . j a v a2 s . c o m*/
using System.Collections.Generic;
using System.Collections.ObjectModel;
public class Demo
{
public static void Main()
{
Collection<string> myData = new Collection<string>();
myData.Add("A");
myData.Add("B");
myData.Add("C");
myData.Add("D");
Console.WriteLine("{0} myData:", myData.Count);
}
}
The code above generates the following result.