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

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

By , 24 Jan 2012
Rate this:
Please Sign up or sign in to vote.
If you're stuck with .NET 3.5, you can use the Aggregate extension method[^]:
string cities_string = cities.Aggregate(new StringBuilder(), (sb, c) =>
    if (0 != sb.Length) sb.Append(", ");
    return sb;
}, sb => sb.ToString());


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

About the Author

Richard Deeming
Software Developer Nevalee Business Solutions
United Kingdom United Kingdom
No Biography provided
Follow on   Twitter   Google+

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140421.2 | Last Updated 24 Jan 2012
Article Copyright 2012 by Richard Deeming
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid