public string SimpleStringBuilder() { using (var builder = new SimpleStringBuilder(s.Length + 1)) { builder.Append(c); builder.Append(s); return(builder.ToString()); } }
public void SimpleStringBuilder_AppendChar() { using var builder = new SimpleStringBuilder(N + 4); var c = X; for (var i = 0; i < N; i++) { // ReSharper disable once PossiblyImpureMethodCallOnReadonlyVariable builder.Append(c); } _str = builder.ToString(); }
public void Test_StringBuilder() { using var sb = new SimpleStringBuilder(100); sb.Append(' '); sb.Append('1'); sb.Append('2'); sb.Append('3'); sb.Append('4'); sb.Append("Some text"); sb.Append(ReadOnlySpan <char> .Empty); sb.Append((string)null); sb.Append('W', 'T', 'F'); var s = sb.ToString(); Assert.AreEqual(" 1234Some textWTF", s); Assert.IsFalse(sb.View().IsEmpty); sb.Clear(); Assert.IsTrue(sb.View().IsEmpty); }