The concatenation in many language using the +=
operator create a new string instance. It is preffered to use a string[]
that we join at the end.
In Javascript :
var myString = new Array("Hello");
myString.push(" ");
myString.push("world !");
console.log(myString.join(''));
is more efficient that :
var myString = "Hello";
myString += " ";
myString += "world !";
console.log(myString);
In C#, does the +=
operator create a new string ?
Is the StringBuilder more efficient that using a string[]
?