Ive read a few posts on here and the common suggestion is that stringbuilder is the most efficent if joining over three strings.
all variables are other properties.
public string Summary
{
get
{
return Name.Replace("_", " ") + "<strong>[" + Total + " Devices - " + BadCount + " Offline, " + PendingCount + " Pending]</strong>";
}
}
Im joining four, is a simple concatenation suitable or should I ue stringbuilder? Just seems a little overkill.
Use whatever is most readable in this case. Otherwise it’s premature optimization.
I would use
String.Format:Even string concatenation is not that bad since strings are stored in the intern pool. So if you use a string a second time it’s not created but the already available reference is used.
So as rule of thumb:
String.Format+(string concatenation)StringBuilder