Here’s the code that demonstrates how one can get the total number of elements contained in the ArrayList using C# using the Count property of the ArrayList.

How to Get the number of elements in ArrayList in C# ?

using System;
using System.Collections;

namespace ACConsoleApp1
    class Program
        static void Main(string[] args)
            ArrayList movies = new ArrayList(5);
            movies.Add("Robo 2.0");

            // Gets the total elements from ArrayList using Count property
            var totalElements = movies.Count;
            Console.WriteLine("Total Elements in Array List =" + totalElements);

Leave a Reply

Your email address will not be published. Required fields are marked *

Liked this content?. Please spread the word :)

  • RSS
  • Twitter
    Visit Us
    Follow Me