C# Collection Count
Description
gets the number of elements actually contained in the Collection.
Syntax
public int Count { get; }
Example
using System;//ww w. j a v a 2s .com
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.