Murali Kris

Murali Kris

  • 1.7k
  • 201
  • 6.6k

Split string from List<string> to a string.

Nov 5 2018 5:16 AM
Hi,
 
how can i split string from List <string> list .
here is the code:
char[] mychars {;}
List<string> textn = new List<string>(new[] { row["PERMISSIONS"].ToString() }); // row[per] from datatable.
//textn returns some data like one,two,three 
string lines;
lines = textn.ToString(); // assigning to lines  it returns (=System.String[])
string[] names = lines.Split(mychars, StringSplitOptions.None);
//string[] names = lines.Split(mychars);  tried but no luck same error.
foreach (var item in names)
{
Console.WriteLine(item.ToString()); // returns =System.String[]
}
 
input from datatable is one;two;three;four
expected output  is one \n two \n three \n four
Any help here.
 

Answers (3)