Click here to Skip to main content
Click here to Skip to main content
Alternative Tip
Go to top

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

, 4 Feb 2012
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 | Mobile
Web01 | 2.8.140916.1 | Last Updated 4 Feb 2012
Article Copyright 2012 by jarvisa
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid