Closed
Description
Background and Motivation
StringBuilder has several overloads, but none of them work with an interpolated string without first turning it into a string. Given that purpose of the StringBuilder is performance, it seems like turning the interpolation into a string first is going to give a performance hit.
Proposed API
namespace System.Text
{
public sealed class StringBuilder : System.Runtime.Serialization.ISerializable
{
+ public StringBuilder AppendFormat(IFormattable)
}
}
Usage Examples
const string lastName = "Moreno";
const string firstName = "John";
var sb = new StringBuilder();
IFormattable name = $"{lastName}, {firstName}";
sb.AppendFormat(name);
-->
Risks
It's possible that the implementation for the overload would be slower than sb.AppendFormat("{0}, {1}", lastName, firstName);