In this Blog we are going to see. How to Convert ARRAY to Generic
List using C#
Used Namespace:
using System.Collections.Generic;
Code Snippet:
/// <summary>
/// This Converts List To
Array
/// </summary>
public void
ConvertingArrayToLIst()
{
//Declare Array
string[] array = { "Lajapathy",
"Arun" };
//Convert Array to List
List<string>
list = new List<string>(array);
//Displaying the Array Value.
foreach (string s in list)
{
Console.WriteLine(Environment.NewLine);
Console.WriteLine(s);
}
List<string>
list1 = new List<string>();
list1.AddRange(array);
//Displaying the Array Value.
foreach (string s in list1)
{
Console.WriteLine(Environment.NewLine);
Console.WriteLine(s);
}
}
Output:
Lajapathy
Arun
Lajapathy
Arun
Thanks for reading this article. Have a nice day.