I just saw code like
StringBuilder result = new StringBuilder(); for (int i = 0; i < n; i++) { result.Append("?"); } return result.ToString();
I know that concatenation with StringBuilder counts faster (and does not create a new string instance for every addition). But is there any reason why we would not want to write
return new string('?', n)
instead
Nickolodeon
source share