How can I write a Linq expression (or anything else) that select item from a List and join them together ?
Example
IList<string> data = new List<string>(); data.Add("MyData1"); data.Add("MyData2"); string result = //some linq query... I try data.Select(x => x + ","); //result = "MyData1, MyData2"
Why not just go with (String.Join Method)
string joined = String.Join(",", data.ToArray());
But if it has to be LINQ, you could try
string joinedLinq = data.Aggregate((i, j) => i + "," + j);
1.4m articles
1.4m replys
5 comments
57.0k users