What is the Count property of ArrayList class in C#?

CsharpProgrammingServer Side Programming

The Count property in the ArrayList class counts the number of elements in the ArrayList.

Firstly, add elements to the ArrayList −

ArrayList arrList = new ArrayList();

arrList.Add(98);
arrList.Add(55);
arrList.Add(65);
arrList.Add(34);

Then get the count of the array list −

arrList.Count

The following is the code to implement Count property in C# −

Example

 Live Demo

using System;
using System.Collections;

class Demo {
   public static void Main() {
      ArrayList arrList = new ArrayList();

      arrList.Add(98);
      arrList.Add(55);
      arrList.Add(65);
      arrList.Add(34);

      Console.WriteLine("Count = " + arrList.Count);

   }
}

Output

Count = 4
raja
Published on 07-Aug-2018 08:12:59
Advertisements