6.2 StringBuilder Class

The StringBuilder class represents mutable strings. It starts at a predefined size (16 characters, by default) and grows dynamically as more characters are added. It can grow either unbounded or up to a configurable maximum. For example:

using System;
using System.Text;
class TestStringBuilder {
  static void Main( ) {
    StringBuilder sb = new StringBuilder("Hello, ");
    sb[11] = '!';
    Console.WriteLine(sb); // Hello, World!

    Part II: Programming with the .NET Framework
    Part IV: API Quick Reference