Use the StringBuilder class for concatenating large numbers of strings
Do
var builder = new StringBuilder();
foreach (var word in words)
{
builder.Append(word).Append(' ');
}
string result = builder.ToString();
BEST
Span<char> buffer = stackalloc char[1024];
var pos = 0;
foreach (var word in words)
{
word.AsSpan().CopyTo(buffer.Slice(pos));
pos += word.Length;
buffer[pos++] = ' ';
}
string result = new string(buffer.Slice(0, pos));
Don't
string result = "";
foreach (var word in words)
{
result += word + " ";
}