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"); movies.Add("Kabali"); // Gets the total elements from ArrayList using Count property var totalElements = movies.Count; Console.WriteLine("Total Elements in Array List =" + totalElements); Console.ReadLine(); } } }
Leave a Reply