In this articleI will explain how to convert String array to List using C#. we can achieve byusing .ToList() on array types, this seems to be available only in .Net 3.5+.
using System.Collections.Generic;
static void Main(string[] args)
{
try
{
string[] array = { "hi", "how", "are", "you", "?" };
List<string> list = array.ToList();
foreach (string item in list)
{
Console.WriteLine(item);
}
}
catch(Exception ex) {
Console.WriteLine(ex.ToString());
}
Console.ReadLine();
}
Output:
Hi
How
Are
You
?
Post your comments / questions
Recent Article
- Fix-Gradient effect turning to gray in after effects
- How to blur an image in python?
- ModuleNotFoundError: No module named 'whois' in Python GoviralHost Without Terminal
- How to Convert Image to Pencil Sketch in Python?
- AttributeError: module 'urllib' has no attribute 'request' - Python
- How to Extract audio from video files using python?
- PermissionError: [Errno 13] Permission denied: 'shampoo_sales.csv' - Python
- [WinError 145] The directory is not empty: 'FolderPath' - Python
Related Article