Does StringBuilder cache the resulting string upon ToString() call?

Viewed 628

Does StringBuilder cache the string upon ToString call? For example, will this create two different in-memory strings, or use just one:

var sb = new StringBuilder();
sb.Append("foo");
sb.Append("bar");

var str1 = sb.ToString();
var str2 = sb.ToString();

Will it cache its own result for consecutive read operations?

5 Answers
Related