I need to concatenate a lot of strings alltogether and put a comma between any of them. I have a list of strings
\"123123123213\"
\"1232113213213\"
\"1232131
Your second solution adds an extra ,
at the end. Take a look at Eric Lippert`s blog entry
I would recommend fixing your second solution. A StringBuilder would be definitely faster, as you avoid coping the list contents to a new array.
StringBuilder builder = new StringBuilder();
string separator = "";
stringList.ForEach(
val =>
{
builder.Append(separator).Append(val);
separator = ",";
});
string outcome = builder.ToString();