Linq to get the values with Comma seperated.

Here is the LINQ to convert your LINQ result into a comma separated value:

string returnVal = (from a in b
select a.StringValue).Aggregate(new StringBuilder(),
(c, d) => c.Append(",").Append(@"""" + d + @""""),
(c) => c.ToString().TrimStart(new char[] { ',' })
.TrimEnd(new char[] { ',' }))

Example:


customerTrips = (from a in dtReceiptAmountDetails.AsEnumerable()
select a.Field("Customer_TripId").ToString()).Aggregate(new StringBuilder(),
(c, d) => c.Append(",").Append(d),
(c) => c.ToString().TrimStart(new char[] { ',' })
.TrimEnd(new char[] { ',' }));

dtReceiptAmountDetails ---> Data Table
Customer_TripId ---> Column Name.