August 2003
Intermediate to advanced
928 pages
32h 1m
English
StringBuilder
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(intcapacity); public StringBuilder(intcapacity, intmaxCapacity); public StringBuilder(stringvalue); public StringBuilder(stringvalue, intcapacity); public StringBuilder(stringvalue, intstartIndex, intlength, intcapacity); // Public Instance Properties public int Capacity{set; get; } public int Length{set; get; } public int MaxCapacity{get; } public char this[intindex]{set; get; } // Public Instance Methods public StringBuilder Append(boolvalue); public StringBuilder Append(bytevalue); public StringBuilder Append(charvalue); public StringBuilder Append(char[ ]value); public StringBuilder Append(char[ ]value, intstartIndex, intcharCount); public StringBuilder Append(charvalue, intrepeatCount ...