How to Count number of items in a C# List

How to get number of items in a List with C#

The Count property gets the total actual number of items in list.

The following code snippet display number of items in a list.

// Create a list of strings
List<string> AuthorList = new List<string>();
AuthorList.Add("Mahesh Chand");
AuthorList.Add("Praveen Kumar");
AuthorList.Add("Raj Kumar");
AuthorList.Add("Nipun Tomar");
AuthorList.Add("Dinesh Beniwal");

// Count
Console.WriteLine("Count: {0}", AuthorList.Count);

Download Free book: Programming List with C#

Up Next
    Ebook Download
    View all
    View all