Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 569 Bytes

MA0028.md

File metadata and controls

31 lines (22 loc) · 569 Bytes

MA0028 - Optimize StringBuilder usage

new StringBuilder().Append($"a{10}");
new StringBuilder().Append("a" + 10);

// Should be
new StringBuilder().Append("a").Append(10);
new StringBuilder().Append("a");

// Should be
new StringBuilder().Append('a');
new StringBuilder().Append(10.ToString());

// Should be
new StringBuilder().Append(10);
new StringBuilder().Append(10.ToString("n1", CultureInfo.CurrentCulture));

// Should be
new StringBuilder().AppendFormat(CultureInfo.CurrentCulture, "{0:n1}", 10);