Lets say i have a string array like this,
string[] array1 = {
"<p>here is a big sentence</p>",
"file1",
"file2",
"<p>this is a big paragraph</p>",
"file3",
"file4",
"file5",
"<p>this is another paragraph</p>",
};
i want to convert this to,
string[] array2 = {
"<p>here is a big sentence</p>",
"file1,file2",
"<p>this is a big paragraph</p>",
"file3,file4,file5",
"<p>this is another paragraph</p>",
};
i need to concat strings, inside an array, based on a condition, that they don't have a <p></p>
tag.
what is cleanest way to do this, is there a correct way to do this? with or without linq?
var array2 = array1.GroupIf((s1, s2) => !s1.StartsWith("<p>") && !s2.StartsWith("<p>")).Select(g => string.Join(", ", g)).ToArray();