c# - Comma separated using string.Join with LINQ -
i used string.join in lambda expression form comma seperated values
i achieved using following code:
var viewdata = queue.select(items => new companyqueuewithseginfo() { segmentname = string.join(",", items.select(i => i.seginfo.trim())); }).asqueryable() }
the output :
ab ,cd
but need output as
ab, cd
i tried this:
string.join(" ,",items.select(i => i.segminfo)).replace(",", ", ").replace(" ,","")
can me this? didn't work.
if seginfo
string
, how trim
them first , then join ", "
?
string.join(", ", items.select(i => i.seginfo.trim()));
also should check item null
or not prevent nre like;
string.join(", ", list.where(s => s != null).select(i => i.trim()))
or can use isnullorempty
others mentioned.
Comments
Post a Comment