I am using the following:
return string.Join(\"\\n\", parts);
Parts has 7 entries but two of them are the empty string \"\". How can I fi
An alternate way of doing this is by using StringSplitOptions.RemoveEmptyEntries:
e.g.
string yourString = "The|quick||brown|||fox|is|here";
char[] delimiter = new char[] { '|' };
string result = string.Join(",", yourString.Split(delimiter, StringSplitOptions.RemoveEmptyEntries));
This gives:
The,quick,brown,fox,is,here
@Stefan Steiger:
string yourString = "echo 'foo' | sed '/foo/d;'";
This gives:
echo 'foo' , sed '/foo/d;'
Which is as I would expect. See the dotnetfiddle of it.