Possible Duplicate:
开发者_C百科 What is the LINQ way to implode/join a string array?
Say I have a linq query that returns a generic list containing a single string element:
//Actually comes from a linq to sql query so I don't actually have the array.
string[] mer = {"cat","dog","fish"};
var k = (from k in mer
select k);
Is there a quick convenient way to print the results k in a string like: "cat, dog, fish" using projections?
I know I can simply use a foreach loop and += them into a string variable if there isn't a neat way.
Use String.Join()
- it allows you to specify a delimiter, and joins a given collection of strings into a single string joined by that delimiting character / string.
It's not Linq but it solves your problem.
精彩评论