In many places in our code we have collections of objects, from which we need to create a comma-separated list. The type of collection varies: it may be a DataTable from whi
I love Matt Howells answer in this post:
I had to make it into an extension:
public static string ToCsv(this IEnumerable things, Func toStringMethod)
Usage: [ I am getting all the emails and turning them into a csv string for emails ]:
var list = Session.Find("from User u where u.IsActive = true").Cast();
return list.ToCsv(i => i.Email);