ToString method in ArrayList

In this article I will explain the ToString method of ArrayList.
  • 2616

Introduction

The ToString method of ArrayList returns a string that represents the current object.ToString method specifies the current object of the string.

Example

namespace ConsoleApplication6

{

    class Program

    {

        static void Main(string[] args)

        {

            // Creates a new ArrayList.

            ArrayList arraylist = new ArrayList();

            var a= arraylist.Add("One");

            arraylist.Add("Two");

            arraylist.Add("Three");

            arraylist.Add("Four");

            var b=arraylist.Add("Five");

            arraylist.Add("Six");

            arraylist.Add("Seven");

            arraylist.Add("Eight");

            arraylist.Add("Nine");

            //use of ToString method

            Console.WriteLine(arraylist.ToString());

            Console.WriteLine(a.ToString());

            Console.WriteLine(b.ToString());

        }

    }

}

 

Output

tostring.jpg 

 

Ask Your Question  

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

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.