Make CSV from list of string in LINQ

There are not any one liners to do this with LINQ. Note that you can use the Aggregate method to do this, but you will be using string concatenation instead of a StringBuilder. I would consider adding an extension method for this if it something you will be doing often:

public static string ToCsv(this IEnumerable source)
if (source == null) throw new ArgumentNullException("source");
return string.Join(",", source.Select(s => s.ToString()).ToArray());


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s