<p>I understand the difference between <code>String</code> and <code>StringBuilder</code> (<code>StringBuilder</code> being mutable) but is there a large performance difference between the two? </p>

<p>The program I’m working on has a lot of case driven string appends (500+). Is using <code>StringBuilder</code> a better choice?</p>

[{'answer_id': 73901, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': -1, 'selected': False, 'text': '<p>StringBuilder will perform better, from a memory stand point. As for processing, the difference in time of execution may be negligible.</p>\n'}, {'answer_id': 73921, 'author': 'Gilligan', 'author_id': 12356, 'author_profile': 'https://Stackoverflow.com/users/12356', 'pm_score': 1, 'selected': False, 'text': '<p>I believe StringBuilder is faster if you have more than 4 strings you need to append together. Plus it can do some cool things like AppendLine.</p>\n'}, {'answer_id': 73925, 'author': 'Eric Z Beard', 'author_id': 1219, 'author_profile': 'https://Stackoverflow.com/users/1219', 'pm_score': 1, 'selected': False, 'text': "<p>In .NET, StringBuilder is still faster than appending strings.  I'm pretty sure that in Java, they just create a StringBuffer under the hood when you append strings, so there's isn't really a difference.  I'm not sure why they haven't done this in .NET yet.</p>\n"}, {'answer_id': 73929, 'author': 'Jay Bazuzi', 'author_id': 5314, 'author_profile': 'https://Stackoverflow.com/users/5314', 'pm_score': 9, 'selected': True, 'text': '<p>Yes, the performance difference is significant.  See the KB article "<a href="http://support.microsoft.com/kb/306822" rel="noreferrer">How to improve string concatenation performance in Visual C#</a>".</p>\n\n<p>I have always tried to code for clarity first, and then optimize for performance later.  That\'s much easier than doing it the other way around! However, having seen the enormous performance difference in my applications between the two, I now think about it a little more carefully.  </p>\n\n<p>Luckily, it\'s relatively straightforward to run performance analysis on your code to see where you\'re spending the time, and then to modify it to use <code>StringBuilder</code> where needed.</p>\n'}, {'answer_id': 73942, 'author': 'deemer', 'author_id': 11192, 'author_profile': 'https://Stackoverflow.com/users/11192', 'pm_score': -1, 'selected': False, 'text': "<p>StringBuilder is probably preferable.  The reason is that it allocates more space than currently needed (you set the number of characters) to leave room for future appends.  Then those future appends that fit in the current buffer don't require any memory allocation or garbage collection, which can be expensive.  In general, I use StringBuilder for complex string concatentation or multiple formatting, then convert to a normal String when the data is complete, and I want an immutable object again.</p>\n"}, {'answer_id': 73945, 'author': 'Alex Fort', 'author_id': 12624, 'author_profile': 'https://Stackoverflow.com/users/12624', 'pm_score': 0, 'selected': False, 'text': "<p>If you're doing a lot of string concatenation, use a StringBuilder. When you concatenate with a String, you create a new String each time, using up more memory.</p>\n\n<p>Alex</p>\n"}, {'answer_id': 73961, 'author': 'RichS', 'author_id': 6247, 'author_profile': 'https://Stackoverflow.com/users/6247', 'pm_score': 2, 'selected': False, 'text': '<p>Further to the previous answers, the first thing I always do when thinking of issues like this is to create a small test application.  Inside this app, perform some timing test for both scenarios and see for yourself which is quicker.</p>\n\n<p>IMHO, appending 500+ string entries should definitely use StringBuilder.</p>\n'}, {'answer_id': 74028, 'author': 'Steve g', 'author_id': 12092, 'author_profile': 'https://Stackoverflow.com/users/12092', 'pm_score': 1, 'selected': False, 'text': "<p>Using strings for concatenation can lead to a runtime complexity on the order of <code>O(n^2)</code>.</p>\n\n<p>If you use a <code>StringBuilder</code>, there is a lot less copying of memory that has to be done.  With the <code>StringBuilder(int capacity)</code> you can increase performance if you can estimate how large the final <code>String</code> is going to be.  Even if you're not precise, you'll probably only have to grow the capacity of <code>StringBuilder</code> a couple of times which can help performance also.</p>\n"}, {'answer_id': 74053, 'author': 'moswald', 'author_id': 8368, 'author_profile': 'https://Stackoverflow.com/users/8368', 'pm_score': 3, 'selected': False, 'text': '<p>StringBuilder reduces the number of allocations and assignments, at a cost of extra memory used.  Used properly, it can completely remove the need for the compiler to allocate larger and larger strings over and over until the result is found.</p>\n\n<pre><code>string result = "";\nfor(int i = 0; i != N; ++i)\n{\n   result = result + i.ToString();   // allocates a new string, then assigns it to result, which gets repeated N times\n}\n</code></pre>\n\n<p>vs.</p>\n\n<pre><code>String result;\nStringBuilder sb = new StringBuilder(10000);   // create a buffer of 10k\nfor(int i = 0; i != N; ++i)\n{\n   sb.Append(i.ToString());          // fill the buffer, resizing if it overflows the buffer\n}\n\nresult = sb.ToString();   // assigns once\n</code></pre>\n'}, {'answer_id': 74055, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>My approach has always been to use StringBuilder when concatenating 4 or more strings \nOR\nWhen I don\'t know how may concatenations are to take place.</p>\n\n<p><a href="http://www.heikniemi.net/hc/archives/000124.html" rel="nofollow noreferrer">Good performance related article on it here</a></p>\n'}, {'answer_id': 74094, 'author': 'capgpilk', 'author_id': 11707, 'author_profile': 'https://Stackoverflow.com/users/11707', 'pm_score': 0, 'selected': False, 'text': '<p>String and StringBuilder are actually both immutable, the StringBuilder has built in buffers which allow its size to be managed more efficiently. When the StringBuilder needs to resize is when it is re-allocated on the heap. By default it is sized to 16 characters, you can set this in the constructor.</p>\n\n<p>eg.</p>\n\n<p>StringBuilder sb = new StringBuilder(50);</p>\n'}, {'answer_id': 74136, 'author': 'James Curran', 'author_id': 12725, 'author_profile': 'https://Stackoverflow.com/users/12725', 'pm_score': 6, 'selected': False, 'text': '<p>To clarify what Gillian said about 4 string, if you have something like this:</p>\n\n<pre><code>string a,b,c,d;\n a = b + c + d;\n</code></pre>\n\n<p>then it would be faster using strings and the plus operator. This is because (like Java, as Eric points out), it internally uses StringBuilder automatically (Actually, it uses a primitive that StringBuilder also uses)</p>\n\n<p>However, if what you are doing is closer to:</p>\n\n<pre><code>string a,b,c,d;\n a = a + b;\n a = a + c;\n a = a + d;\n</code></pre>\n\n<p>Then you need to explicitly use a StringBuilder.  .Net doesn\'t automatically create a StringBuilder here, because it would be pointless.  At the end of each line, "a" has to be an (immutable) string, so it would have to create and dispose a StringBuilder on each line.  For speed, you\'d need to use the same StringBuilder until you\'re done building:</p>\n\n<pre><code>string a,b,c,d;\nStringBuilder e = new StringBuilder();\n e.Append(b);\n e.Append(c);\n e.Append(d);\n a = e.ToString();\n</code></pre>\n'}, {'answer_id': 74233, 'author': 'Matt Trunnell', 'author_id': 12894, 'author_profile': 'https://Stackoverflow.com/users/12894', 'pm_score': 5, 'selected': False, 'text': '<p>This benchmark shows that regular concatenation is faster when combining 3 or fewer strings.</p>\n\n<p><a href="http://www.chinhdo.com/20070224/stringbuilder-is-not-always-faster/" rel="noreferrer">http://www.chinhdo.com/20070224/stringbuilder-is-not-always-faster/</a></p>\n\n<p>StringBuilder can make a very significant improvement in memory usage, especially in your case of adding 500 strings together.  </p>\n\n<p>Consider the following example:</p>\n\n<pre><code>string buffer = "The numbers are: ";\nfor( int i = 0; i &lt; 5; i++)\n{\n    buffer += i.ToString();\n}\nreturn buffer;\n</code></pre>\n\n<p>What happens in memory?  The following strings are created:</p>\n\n<pre><code>1 - "The numbers are: "\n2 - "0"\n3 - "The numbers are: 0"\n4 - "1"\n5 - "The numbers are: 01"\n6 - "2"\n7 - "The numbers are: 012"\n8 - "3"\n9 - "The numbers are: 0123"\n10 - "4"\n11 - "The numbers are: 01234"\n12 - "5"\n13 - "The numbers are: 012345"\n</code></pre>\n\n<p>By adding those five numbers to the end of the string we created 13 string objects!  And 12 of them were useless!  Wow!</p>\n\n<p>StringBuilder fixes this problem.  It is not a "mutable string" as we often hear (<em>all strings in .NET are immutable</em>).  It works by keeping an internal buffer, an array of char.  Calling Append() or AppendLine() adds the string to the empty space at the end of the char array; if the array is too small, it creates a new, larger array, and copies the buffer there.  So in the example above, StringBuilder might only need a single array to contain all 5 additions to the string-- depending on the size of its buffer.  You can tell StringBuilder how big its buffer should be in the constructor.</p>\n'}, {'answer_id': 74596, 'author': 'Jason Jackson', 'author_id': 13103, 'author_profile': 'https://Stackoverflow.com/users/13103', 'pm_score': 1, 'selected': False, 'text': '<p>I have seen significant performance gains from using the <code>EnsureCapacity(int capacity)</code> method call on an instance of <code>StringBuilder</code> before using it for any string storage. I usually call that on the line of code after instantiation. It has the same effect as if you instantiate the <code>StringBuilder</code> like this:</p>\n\n<pre><code>var sb = new StringBuilder(int capacity);\n</code></pre>\n\n<p>This call allocates needed memory ahead of time, which causes fewer memory allocations during multiple <code>Append()</code> operations.  You have to make an educated guess on how much memory you will need, but for most applications this should not be too difficult. I usually err on the side of a little too much memory (we are talking 1k or so).</p>\n'}, {'answer_id': 75003, 'author': 'calebjenkins', 'author_id': 13199, 'author_profile': 'https://Stackoverflow.com/users/13199', 'pm_score': 5, 'selected': False, 'text': '<p>StringBuilder is preferable <em>IF</em> you are doing multiple loops, or forks in your code pass... however, for PURE performance, if you can get away with a <em>SINGLE</em> string declaration, then that is much more performant. </p>\n\n<p>For example: </p>\n\n<pre><code>string myString = "Some stuff" + var1 + " more stuff"\n                  + var2 + " other stuff" .... etc... etc...;\n</code></pre>\n\n<p>is more performant than</p>\n\n<pre><code>StringBuilder sb = new StringBuilder();\nsb.Append("Some Stuff");\nsb.Append(var1);\nsb.Append(" more stuff");\nsb.Append(var2);\nsb.Append("other stuff");\n// etc.. etc.. etc..\n</code></pre>\n\n<p>In this case, StringBuild could be considered more maintainable, but is not more performant than the single string declaration. </p>\n\n<p>9 times out of 10 though... use the string builder. </p>\n\n<p>On a side note: string + var is also more performant that the string.Format approach (generally) that uses a StringBuilder internally (when in doubt... check reflector!)</p>\n'}, {'answer_id': 75253, 'author': 'raffimd', 'author_id': 13128, 'author_profile': 'https://Stackoverflow.com/users/13128', 'pm_score': 0, 'selected': False, 'text': '<p>String concatenation will cost you more.\nIn Java, You can use either StringBuffer or StringBuilder based on your need.\nIf you want a synchronized, and thread safe implementation, go for StringBuffer. This will be faster than the String concatenation.</p>\n\n<p>If you do not need synchronized or Thread safe implementation, go for StringBuilder.\nThis will be faster than String concatenation and also faster than StringBuffer as their is no synchorization overhead.</p>\n'}, {'answer_id': 75301, 'author': 'user13288', 'author_id': 13288, 'author_profile': 'https://Stackoverflow.com/users/13288', 'pm_score': -1, 'selected': False, 'text': '<p>As a general rule of thumb, if I have to set the value of the string more than once, or if there are any appends to the string, then it needs to be a string builder. I have seen applications that I have written in the past before learning about string builders that have had a huge memory foot print that just seems to keep growing and growing. Changing these programs to use the string builder cut down the memory usage significantly. Now I swear by the string builder.</p>\n'}, {'answer_id': 76664, 'author': 'JasonTrue', 'author_id': 13433, 'author_profile': 'https://Stackoverflow.com/users/13433', 'pm_score': 2, 'selected': False, 'text': '<p><code>StringBuilder</code> is better for building up a string from many non-constant values.</p>\n\n<p>If you\'re building up a string from a lot of constant values, such as multiple lines of values in an HTML or XML document or other chunks of text, you can get away with just appending to the same string, because almost all compilers do "constant folding", a process of reducing the parse tree when you have a bunch of constant manipulation (it\'s also used when you write something like <code>int minutesPerYear = 24 * 365 * 60</code>). And for simple cases with non-constant values appended to each other, the .NET compiler will reduce your code to something similar to what <code>StringBuilder</code> does.</p>\n\n<p>But when your append can\'t be reduced to something simpler by the compiler, you\'ll want a <code>StringBuilder</code>. As fizch points out, that\'s more likely to happen inside of a loop.</p>\n'}, {'answer_id': 3070753, 'author': 'Jim G.', 'author_id': 109941, 'author_profile': 'https://Stackoverflow.com/users/109941', 'pm_score': 2, 'selected': False, 'text': '<p>Consider \'<a href="http://www.codinghorror.com/blog/2009/01/the-sad-tragedy-of-micro-optimization-theater.html" rel="nofollow noreferrer">The Sad Tragedy of Micro-Optimization Theater</a>\'.</p>\n'}, {'answer_id': 4019882, 'author': 'user487069', 'author_id': 487069, 'author_profile': 'https://Stackoverflow.com/users/487069', 'pm_score': 3, 'selected': False, 'text': '<blockquote>\n  <p>The performance of a concatenation operation for a String or StringBuilder object depends on how often a memory allocation occurs. A String concatenation operation always allocates memory, whereas a StringBuilder concatenation operation only allocates memory if the StringBuilder object buffer is too small to accommodate the new data. Consequently, the String class is preferable for a concatenation operation if a fixed number of String objects are concatenated. In that case, the individual concatenation operations might even be combined into a single operation by the compiler. A StringBuilder object is preferable for a concatenation operation if an arbitrary number of strings are concatenated; for example, if a loop concatenates a random number of strings of user input.</p>\n</blockquote>\n\n<p>Source: <a href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder%28v=VS.90%29.aspx" rel="noreferrer">MSDN</a></p>\n'}, {'answer_id': 14567185, 'author': 'CathalMF', 'author_id': 1680271, 'author_profile': 'https://Stackoverflow.com/users/1680271', 'pm_score': 1, 'selected': False, 'text': "<p><code>StringBuilder</code> is significantly more efficient but you will not see that performance unless you are doing a large amount of string modification.</p>\n<p>Below is a quick chunk of code to give an example of the performance. As you can see you really only start to see a major performance increase when you get into large iterations.</p>\n<p>As you can see the 200,000 iterations took 22 seconds while the 1 million iterations using the <code>StringBuilder</code> was almost instant.</p>\n<pre><code>string s = string.Empty;\nStringBuilder sb = new StringBuilder();\n\nConsole.WriteLine(&quot;Beginning String + at &quot; + DateTime.Now.ToString());\n\nfor (int i = 0; i &lt;= 50000; i++)\n{\n    s = s + 'A';\n}\n\nConsole.WriteLine(&quot;Finished String + at &quot; + DateTime.Now.ToString());\nConsole.WriteLine();\n\nConsole.WriteLine(&quot;Beginning String + at &quot; + DateTime.Now.ToString());\n\nfor (int i = 0; i &lt;= 200000; i++)\n{\n    s = s + 'A';\n}\n\nConsole.WriteLine(&quot;Finished String + at &quot; + DateTime.Now.ToString());\nConsole.WriteLine();\nConsole.WriteLine(&quot;Beginning Sb append at &quot; + DateTime.Now.ToString());\n\nfor (int i = 0; i &lt;= 1000000; i++)\n{\n    sb.Append(&quot;A&quot;);\n}\nConsole.WriteLine(&quot;Finished Sb append at &quot; + DateTime.Now.ToString());\n\nConsole.ReadLine();\n</code></pre>\n<p>Result of the above code:</p>\n<blockquote>\n<p>Beginning String + at 28/01/2013 16:55:40.</p>\n<p>Finished String + at 28/01/2013 16:55:40.</p>\n<p>Beginning String + at 28/01/2013 16:55:40.</p>\n<p>Finished String + at 28/01/2013 16:56:02.</p>\n<p>Beginning Sb append at 28/01/2013 16:56:02.</p>\n<p>Finished Sb append at 28/01/2013 16:56:02.</p>\n</blockquote>\n"}, {'answer_id': 17940168, 'author': 'Diizzy', 'author_id': 1701599, 'author_profile': 'https://Stackoverflow.com/users/1701599', 'pm_score': 5, 'selected': False, 'text': '<p>A simple example to demonstrate the difference in speed when using <code>String</code> concatenation vs <code>StringBuilder</code>:</p>\n\n<pre><code>System.Diagnostics.Stopwatch time = new Stopwatch();\nstring test = string.Empty;\ntime.Start();\nfor (int i = 0; i &lt; 100000; i++)\n{\n    test += i;\n}\ntime.Stop();\nSystem.Console.WriteLine("Using String concatenation: " + time.ElapsedMilliseconds + " milliseconds");\n</code></pre>\n\n<p>Result:</p>\n\n<blockquote>\n  <p>Using String concatenation: 15423 milliseconds</p>\n</blockquote>\n\n<pre><code>StringBuilder test1 = new StringBuilder();\ntime.Reset();\ntime.Start();\nfor (int i = 0; i &lt; 100000; i++)\n{\n    test1.Append(i);\n}\ntime.Stop();\nSystem.Console.WriteLine("Using StringBuilder: " + time.ElapsedMilliseconds + " milliseconds");\n</code></pre>\n\n<p>Result:</p>\n\n<blockquote>\n  <p>Using StringBuilder: 10 milliseconds</p>\n</blockquote>\n\n<p>As a result, the first iteration took 15423 ms while the second iteration using <code>StringBuilder</code> took 10 ms.</p>\n\n<p>It looks to me that using <code>StringBuilder</code> is faster, a lot faster.</p>\n'}, {'answer_id': 28749377, 'author': 'Shamseer K', 'author_id': 4133590, 'author_profile': 'https://Stackoverflow.com/users/4133590', 'pm_score': 4, 'selected': False, 'text': '<p>Yes, <code>StringBuilder</code> gives better performance while performing repeated operation over a string. It is because all the changes are made to a single instance so it can save a lot of time instead of  creating a new instance like <code>String</code>.</p>\n\n<h3>String Vs Stringbuilder</h3>\n\n<ul>\n<li><p><code>String</code></p>\n\n<ol>\n<li>under <code>System</code> namespace</li>\n<li>immutable (read-only) instance</li>\n<li>performance degrades when continuous change of value occures</li>\n<li>thread safe</li>\n</ol></li>\n<li><p><code>StringBuilder</code> (mutable string)</p>\n\n<ol>\n<li>under <code>System.Text</code> namespace</li>\n<li>mutable instance</li>\n<li>shows better performance since new changes are made to existing instance</li>\n</ol></li>\n</ul>\n\n<blockquote>\n  <p>Strongly recommend dotnet mob article : <a href="http://codaffection.com/csharp-article/difference-string-and-stringbuilder-in-csharp/" rel="nofollow noreferrer">String Vs StringBuilder in C#</a>.</p>\n  \n  <p>Related Stack Overflow question: <a href="https://stackoverflow.com/questions/28511598/mutability-of-string-when-string-doesnt-change-in-c/28511709#28511709">Mutability of string when string\n  doesn\'t change in C#?</a>.</p>\n</blockquote>\n'}, {'answer_id': 53795136, 'author': 'Rehan Shah', 'author_id': 10759317, 'author_profile': 'https://Stackoverflow.com/users/10759317', 'pm_score': 4, 'selected': False, 'text': '<p><strong>String Vs String Builder:</strong></p>\n\n<p>First thing you have to know that In which assembly these two classes lives?</p>\n\n<p>So,</p>\n\n<p><strong>string</strong> is present in <code>System</code> namespace.</p>\n\n<p>and </p>\n\n<p><strong>StringBuilder</strong> is present in <code>System.Text</code> namespace.</p>\n\n<p>For <strong>string</strong> declaration: </p>\n\n<p>You have to include the <code>System</code> namespace.\nsomething like this.\n<code>Using System;</code></p>\n\n<p>and </p>\n\n<p>For <strong>StringBuilder</strong> declaration: </p>\n\n<p>You have to include the <code>System.text</code> namespace.\nsomething like this.\n<code>Using System.text;</code></p>\n\n<p>Now Come the the actual Question.</p>\n\n<p>What is the differene between <strong>string</strong> &amp; <strong>StringBuilder</strong>?</p>\n\n<p><strong><em>The main difference between these two is that:</em></strong></p>\n\n<p><strong>string</strong> is immutable.</p>\n\n<p>and</p>\n\n<p><strong>StringBuilder</strong> is mutable.</p>\n\n<p>So Now lets discuss the difference between <em>immutable</em> and <em>mutable</em></p>\n\n<p><strong>Mutable:</strong> : means Changable.</p>\n\n<p><strong>Immutable:</strong> : means Not Changable.</p>\n\n<p><strong>For example:</strong></p>\n\n<pre><code>using System;\n\nnamespace StringVsStrigBuilder\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            // String Example\n\n            string name = "Rehan";\n            name = name + "Shah";\n            name = name + "RS";\n            name = name + "---";\n            name = name + "I love to write programs.";\n\n            // Now when I run this program this output will be look like this.\n            // output : "Rehan Shah RS --- I love to write programs."\n        }\n    }\n}\n</code></pre>\n\n<p>So in this case we are going to changing same object 5-times.</p>\n\n<p>So the Obvious question is that ! What is actually happen under the hood, when we change the same string 5-times.</p>\n\n<p>This is What Happen when we change the same string 5-times.</p>\n\n<p>let look at the figure.</p>\n\n<p><a href="https://i.stack.imgur.com/Q3haP.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Q3haP.jpg" alt="enter image description here"></a> </p>\n\n<p><strong>Explaination:</strong></p>\n\n<p>When we first initialize this variable "name" to "Rehan" i-e <code>string name = "Rehan"</code>\nthis variable get created on stack "name" and pointing to that "Rehan" value.\nafter this line is executed: "name = name + "Shah". the reference variable is no longer pointing to that object "Rehan" it now pointing to "Shah" and so on.</p>\n\n<p>So <code>string</code> is immutable meaning that once we create the object in the memory we can\'t change them.</p>\n\n<p>So when we concatinating the <code>name</code> variable the previous object remains there in the memory and another new string object is get created...</p>\n\n<p>So from the above figure we have five-objects the four-objects are thrown away they are not used at all. They stil remain in memory and they occuy the amount of memory.\n"Garbage Collector" is responsible for that so clean that resources from the memory.</p>\n\n<p>So in case of string anytime when we manipulate the string over and over again we have some many objects Created ans stay there at in the memory.</p>\n\n<p>So this is the story of string Variable.</p>\n\n<p>Now Let\'s look at toward StringBuilder Object.\n<strong>For Example:</strong> </p>\n\n<pre><code>using System;\nusing System.Text;\n\nnamespace StringVsStrigBuilder\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            // StringBuilder Example\n\n            StringBuilder name = new StringBuilder();\n            name.Append("Rehan");\n            name.Append("Shah");\n            name.Append("RS");\n            name.Append("---");\n            name.Append("I love to write programs.");\n\n\n            // Now when I run this program this output will be look like this.\n            // output : "Rehan Shah Rs --- I love to write programs."\n        }\n    }\n}\n</code></pre>\n\n<p>So in this case we are going to changing same object 5-times.</p>\n\n<p>So the Obvious question is that ! What is actually happen under the hood, when we change the same StringBuilder 5-times.</p>\n\n<p>This is What Happen when we change the same StringBuilder  5-times.</p>\n\n<p>let look at the figure.\n<a href="https://i.stack.imgur.com/oqTua.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/oqTua.jpg" alt="enter image description here"></a></p>\n\n<p><strong>Explaination:</strong>\nIn case of StringBuilder object. you wouldn\'t get the new object. The same object will be change in memory so even if you change the object et say 10,000 times we will still have only one stringBuilder object.</p>\n\n<p>You don\'t have alot of garbage objects or non_referenced stringBuilder objects because why it can be change. It is mutable meaning it change over a time?</p>\n\n<p><strong>Differences:</strong></p>\n\n<ul>\n<li>String is present in System namespace where as Stringbuilder present\nin System.Text namespace.</li>\n<li>string is immutable where as StringBuilder is mutabe.</li>\n</ul>\n'}]
['https://Stackoverflow.com/questions/73883', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12623/']