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