Converting Generic List to Array using C#

In this Blog we are going to see. How to Convert Generic List to ARRAY using C#
 
Used Namespace:
using System.Collections.Generic;
 
 
Code Snippet:
 

        ///
<summary>
        /// This Converts List To Array
        /// </summary>
        public void ConvertingListTOArray()
        {
            //Adding item to the List
            List<string> list = new List<string>();
            list.Add("Lajapathy");
            list.Add("Arun");
 
            //Convert List to Array
            Array array = list.ToArray();
 
            //Convert List to Array
            string[] array1 = list.ToArray();
 
            //Displaying the Array Value.
            foreach (string s in array1)
            {
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine(s);
            }
        }
 

Output:

Lajapathy
Arun


Thanks for reading this article. Have a nice day.