RemoveAt method in ArrayList

In this article I will explain the RemoveAt method of arraylist.
  • 2461

RemoveAt method removes the element at the specified index of the ArrayList

Example

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            ArrayList arr = new ArrayList();

            arr.Add("Red");

            arr.Add("Pink");

            arr.Add("Orange");

            arr.Add("Yellow");

            arr.Add("Blue");

            arr.Add("Gray");

            arr.Add("White");

            Console.WriteLine("The elements in the arraylist are:");

            foreach (object obj in arr)

            {

                Console.WriteLine(obj);

            }

            arr.RemoveAt(0);

            arr.RemoveAt(4);

            arr.RemoveAt(1);

            arr.RemoveAt(2);

            Console.WriteLine("After perform the RemoveAt operation the arraylist are:");

            foreach (object obj in arr)

            {

                Console.WriteLine(obj);

            }

        }

    }

}


Output

 

removeat.jpg 

 

Further Readings
 
You may also want to read these related articles.

Ask Your Question  

Got a programming related question? You may want to post your question here

 

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.