Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When you use concatenation such as </p> <pre><code>str_orderbycity += ","; </code></pre> <p>A new string is created (if not already existing in <a href="http://brainspeex.wordpress.com/2011/10/30/string-pooling-in-net-c/" rel="nofollow">string intern pool</a>).</p> <p><a href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx" rel="nofollow">StringBuffer</a> avoids those intermediate strings by using maintaining <code>char array</code> only.</p> <p><code>StringBuffer</code> has its costs/overheads so it is not always efficient than <code>String</code> concatenation.</p> <p>From <a href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx" rel="nofollow">String Builder Performance consideration - MSDN</a></p> <blockquote> <p>The performance of a concatenation operation for a String or StringBuilder object depends on the frequency of memory allocations.<br> A String concatenation operation always allocates memory, whereas a StringBuilder concatenation operation allocates memory only if the StringBuilder object buffer is too small to accommodate the new data.<br> Use the String class if you are concatenating a fixed number of String objects. In that case, the compiler may even combine individual concatenation operations into a single operation.<br> Use a StringBuilder object if you are concatenating an arbitrary number of strings; for example, if you're using a loop to concatenate a random number of strings of user input.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload