How to get comma seprated string from List Item

Goldytech
Posted by Goldytech under LINQ category on | Views : 3112
Suppose i want to get the output as comma seprated string from my list here is the code of it.
 private string GetStringFromListItem()
{
List<string> alist = new List<string>();
alist.Add("One");
alist.Add("Two");
alist.Add("Three");

var rtnVal = from x in alist select x;

return string.Join(",", rtnVal.ToArray());
}


You can use this code for LinqToSql also. Very handy code for data conversion and migration projects.

Comments or Responses

Login to post response