65.9K
CodeProject is changing. Read more.
Home

Converting Array or List of data to String => made easy! (C#, MVC3, LINQ)

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.75/5 (4 votes)

Jan 18, 2012

CPOL
viewsIcon

16320

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...

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?