score:0

Accepted answer

You can use Aggregate:

options.Aggregate((current, next) => current + ", " + next);

Note that this generates a new string for each operation, so if your options list is long you are better off using an old school approach with StringBuilder

score:3

While Aggregate will work it has O(n2) performance. If you need better performance you can use string.Join. Unfortunately this method doesn't accept an IEnumerable<string> so you have to also use ToArray to get what you want:

string.Join(", ", options.Select(o => o.Name).ToArray())

Related Articles