If I want to concatenate string N the number of times, which method should I use?
Take this code as an example:
public static string Repeat(this string instance, int times)
{
var result = string.Empty;
for (int i = 0; i < times; i++)
result += instance;
return result;
}
This method can be called with a "time" set to 5 or 5000. Which method should I use?
string.join? StringBuilder? Just a standard string. Concat?
A similar function will be implemented in the commercial library, so I really need an βoptimalβ way to do this.
source
share