Remove method in ArrayList

In this article I will explain the Remove method of arraylist.
  • 2374

Remove method removes the first occurrence of a specific object from 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.Remove("Orange");

            arr.Remove("Gray");

            arr.Remove("White");

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

            foreach (object obj in arr)

            {

                Console.WriteLine(obj);

            }

        }

    }

}


Output

remove.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

© 2020 DotNetHeaven. All rights reserved.