Click here to Skip to main content
11,629,481 members (65,269 online)
Click here to Skip to main content

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

, 4 Feb 2012 CPOL 4.1K
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

You may also be interested in...

Comments and Discussions

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