How to convert array to list in c#.net


Using below example we can convert array to list in c#.net

        static void Main(string[] args)
        {
            //creating an array
            int[] exampleArray = { 1, 2, 3, 4, 5 };
            //convert array to list
            List<int> exampleList = exampleArray.ToList();

            //display list values
            foreach (var data in exampleList)
                Console.WriteLine(data);

            Console.Read();
        }

Output:


If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar