How to get comma seprated string from List Item

Posted by Goldytech under LINQ category on | Views : 3393
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>();

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