Click here to Skip to main content
13,052,714 members (62,727 online)
Click here to Skip to main content
Add your own
alternative version


Posted 3 Feb 2012

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

You may also be interested in...

Comments and Discussions

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