Array to List

Blessyjees
Posted by Blessyjees under C# category on | Points: 40 | Views : 1961
By using this we can easily convert an arrary to list.

string[] dataRows = new string[] { "one", "two", "three" }; 
List<string> dataRowList = new List<string>(dataRows.Length);
dataRowList.AddRange(dataRows);

Comments or Responses

Posted by: Ndebata on: 10/11/2011 Level:Starter | Status: [Member] | Points: 10
If you are using 3.5 or above you can directly use ToList() to do it.
string[] dataRows = new string[] { "one", "two", "three" }; 

List<string> dataRowList = dataRows.ToList();

Login to post response