StringBuilder provides the
Capacity properties to return the number of characters currently in a
StringBuilder and the number of characters that a
String-Builder can store without allocating more memory, respectively. These properties also can increase or decrease the length or the capacity of the
Ensure-Capacity allows you to reduce the number of times that a
StringBuilder’s capacity must be increased. The method ensures that the
StringBuilder’s capacity is at least the specified value. The program in Fig. 16.10 demonstrates these methods and properties.
1 // Fig. 16.10: StringBuilderFeatures.cs ...