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 StringBuilder( );
   public StringBuilder(int capacity);
   public StringBuilder(int capacity, int maxCapacity);
   public StringBuilder(string value);
   public StringBuilder(string value, int capacity);
   public StringBuilder(string value, int startIndex, int length, int capacity);
// Public Instance Properties
   public int Capacity{set; get; }
   public int Length{set; get; }
   public int MaxCapacity{get; }
   public char this[int index]{set; get; }
// Public Instance Methods
   public StringBuilder Append(bool value);
   public StringBuilder Append(byte value);
   public StringBuilder Append(char value);
   public StringBuilder Append(char[ ] value);
   public StringBuilder Append(char[ ] value, int startIndex, int charCount);
   public StringBuilder Append(char value, int repeatCount ...

Get C# in a Nutshell, Second Edition 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.