I want to create a CSV string from the items in a richtextbox. I know there’s got to be a better way than the one I cobbled together:
string CSVDuckbills = GetLinesAsCSV(richTextBoxDuckbills.Lines);
...
private string GetLinesAsCSV(string[] DuckbillLines)
{
string DuckbillCSV = string.Empty;
foreach (string item in DuckbillLines)
{
DuckbillCSV += string.Format("{0},", item);
}
return DuckbillCSV;
}
For one thing, I will have to strip off a superfluous comma at the end.
You can use
string.Joinfor simpler: