Middle
What is the maximum capacity of the StringBuilder class?
sobes.tech AI
Answer from AI
Theoretically, the capacity of StringBuilder is limited by the maximum array size in .NET, which is 2 GB (for 32-bit systems) or 250 GB (for 64-bit systems, depending on GC settings).
However, in practice, the maximum capacity will be limited by the available RAM on the machine. Attempting to exceed this limit may result in an OutOfMemoryException.
Initially, StringBuilder has a small starting capacity, which automatically increases as characters are added. You can explicitly set the initial capacity through the constructor.