Reverse(Int32, Int32) method in ArrayList

In this article I will discuss the Reverse(Int32, Int32) method of ArrayList.
  • 1883

Introduction

Reverse(Int32, Int32) method reverses the order of the elements in the specified range.That means In this method we can give the range of elements that are present in arraylist and only that range of elements will become reverse.Lets take an example of it.

Example

namespace ConsoleApplication3

{

    class Program

    {

        static void Main(string[] args)

        {

            ArrayList arrlist = new ArrayList();

            arrlist.Add("january");

            arrlist.Add("febuary");

            arrlist.Add("march");

            arrlist.Add("april");

            arrlist.Add("may");

            arrlist.Add("june");

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

            foreach (string s in arrlist)

            {

                Console.WriteLine(s);

            }

            arrlist.Reverse(1, 5);

            Console.WriteLine("After reverse method the elements of the arraylist are:");

            foreach (string s in arrlist)

            {

                Console.WriteLine(s);

            }

        }

    }

}


Output

reverse.jpg
 

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

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.