Hi I would like to take a list collection and generate a single csv line. So take this;
List<string> MakeStrings()
{
List<string> results = new List<string>();
results.add("Bob");
results.add("Nancy");
results.add("Joe");
results.add("Jack");
}
string ContactStringsTogether(List<string> parts)
{
StringBuilder sb = new StringBuilder();
foreach (string part in parts)
{
if (sb.Length > 0)
sb.Append(", ");
sb.Append(part);
}
return sb.ToString();
}
This returns "Bob,Nancy,Joe,Jack"
Looking for help on the LINQ to do this in a single statement. Thanks!