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 ...

Get C# in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.