Click here to Skip to main content
15,392,636 members
Articles / General Programming / String
Alternative
Tip/Trick
Posted 3 Feb 2012

Stats

7.9K views

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

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
4 Feb 2012CPOL
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.

License

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

Share

About the Author

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

Comments and Discussions

 
-- There are no messages in this forum --