O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.11. Length and Capacity Properties, EnsureCapacity Method and Indexer of Class StringBuilder

Class StringBuilder provides the Length and 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 StringBuilder. Method 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required