Click here to Skip to main content
11,408,708 members (66,118 online)
Click here to Skip to main content
Alternative Tip/Trick

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

, 4 Feb 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) Shaw Inspection Systems Ltd
United Kingdom United Kingdom
No Biography provided

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150414.5 | Last Updated 4 Feb 2012
Article Copyright 2012 by jarvisa
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid