Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

length of list c#

using System;
using System.Collections.Generic;

namespace ListCount_Example
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initializing the list of strings
            List<string> student_list = new List<string>();

            //Adding values to the list
            student_list.Add("Anna Bower");
            student_list.Add("Ian Mitchell");
            student_list.Add("Dorothy Newman");
            student_list.Add("Nathan Miller");
            student_list.Add("Andrew Dowd");
            student_list.Add("Gavin Davies");
            student_list.Add("Alexandra Berry"); 

            //Getting the count of items in the list and storing it in the student_count variable
            int student_count = student_list.Count;

            //Printing the result
            Console.WriteLine("Total Number of students: " + student_count.ToString()); 
        }
    }
}
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #length #list
ADD COMMENT
Topic
Name
3+7 =