O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

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

Name

StringBuilder

Synopsis

This String helper class enables in-place modification of a string without having to create new string instances. Since strings are immutable, their values cannot change once set. (Attempts to assign a new value to an existing string succeed, but at the expense of destroying and re-creating the original string.) The StringBuilder constructor allows you to set the size of the StringBuilder and specify the initial string it contains. The Insert() methods put new data (of varying types) into the StringBuilder at a specified position. Append() adds data to the end of a StringBuilder. The ToString() method converts the StringBuilder into a real string.

public sealed class StringBuilder {
// Public Constructors
   public method StringBuilder();  
   public method StringBuilder(int capacity);  
   public method StringBuilder(int capacity, 
        int maxCapacity);  
   public method StringBuilder(string value);  
   public method StringBuilder(string value, int capacity);  
   public method StringBuilder(string value, int startIndex, 
        int length, int capacity);  
// Public Instance Properties
   public field int Capacity{set; get; } 
   public field int Length{set; get; } 
   public field int MaxCapacity{get; } 
   public field char this{set; get; } 
// Public Instance Methods
   public method StringBuilder Append(bool value);  
   public method StringBuilder Append(byte value);  
   public method StringBuilder Append(char value);  
   public method StringBuilder Append(char[] value);  
   public method StringBuilder Append(char[] value ...

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