65.9K
CodeProject is changing. Read more.
Home

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

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Feb 3, 2012

CPOL
viewsIcon

8710

string.Join(",...

string.Join(",", Array.ConvertAll(cities, c => c.Name));
A Linq solution that works under .NET 3.5 is:
string.Join(",", cities.Select(c => c.Name).ToArray());
This is less efficient than ConvertAll because it is iterating through the array via the IEnumerable interface.