C# ArrayList Class Tutorial with Examples

C# ArrayList Class Tutorial with Examples

Today, We want to share with you C# ArrayList Class Tutorial with Examples.
In this post we will show you ArrayList in C#.Net, hear for .net – ArrayList vs List<> in C# we will give you demo and example for implement.
In this post, we will learn about C# ArrayList – Features and Usage with an example.

ArrayList in C#.Net

In this post,we will learn about ArrayList in C#.Net with an example.

Now in this post, I will explain about how to get ArrayList in C#.Net with appropriate example.

ArrayList represents an ordered collection of an object that can be indexed individually. It is an alternative to an array. But, unlike an array, you can add and/or remove items from a list at a specified position using an index and the array resizes itself automatically.

READ :  PHP Simple cURL API call using POST

Useful Property


Capacity :

It is use to gets or sets the number of elements that the ArrayList can contain.


It is use to gets the number of elements actually contained in the ArrayList.


It is use to gets a value indicating whether the ArrayList has a fixed size.


It is use to gets a value indicating whether the ArrayList is read-only.


E-junkie: Sell digital downloads online

E-junkie Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!

Also see:

  1. The Top 10+ Best Webinar Software Platforms For 2020-2021
  2. Build Your Future Godaddy Careers And Jobs
  3. Introduction To Web Hosting Services

It is use to gets or sets the element at the specified index.

Useful Method


public virtual int Add(object value)

This methods adds an object to the end of the ArrayList.

public virtual void AddRange(ICollection c)

This methods adds the elements of an ICollection to the end of the ArrayList.

READ :  Vuejs Components and Directives Written using Bootstrap

public virtual void Clear()

This method removes all elements from the ArrayList.

public virtual bool Contains(object item)

This method determines whether an element is in the ArrayList.

Now create Console Application in Visual Studio and write below lines of code in it.

using System;
using System.Collections;
using System.Collections.Generic;

namespace ConsoleDemo
    class Program
        static void Main(string[] args)
            ArrayList _NumberList = new ArrayList();

            Console.WriteLine("Adding some Numbers in ArrayList:");

            Console.WriteLine("Capacity: {0} ", _NumberList.Capacity);
            Console.WriteLine("Count: {0}", _NumberList.Count);

            Console.Write("Content: ");
            foreach (int i in _NumberList)
                Console.Write(i + " ");

            Console.Write("Sorted Content: ");
            foreach (int i in _NumberList)
                Console.Write(i + " ");

Adding some Numbers in ArrayList:
Capacity: 8
Count: 7
Content: 45 78 33 56 12 23 9
Sorted Content: 9 12 23 33 45 56 78

Read :

READ :  AngularJS ui router nested views - AngularJS nested directive controller example


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about C# ArrayList Class.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.