I would just use:
string.Join(",", cities.Select(c=>c.Name))
Since Version 4 of the Framework there is an overloaded versions of string.Join
for IEnumerable
too. It uses a StringBuilder
internally and doesn't insert a seperator after the last element as well.
I could't find the Join
method you mentioned in your last example with the search of my Reflector. Must be an extension to IList
of string?! Where is it defined?