Class StringBuilder
A Micro Framework port of the Full Framework StringBuilder. Contributed by Julius Friedman. Represents a mutable string of characters. This class cannot be inherited.
public sealed class StringBuilder
- Inheritance
-
StringBuilder
- Inherited Members
- Extension Methods
Constructors
StringBuilder()
Initializes a new instance of the StringBuilder class.
public StringBuilder()
StringBuilder(int)
Initializes a new instance of the StringBuilder class using the specified capacity.
public StringBuilder(int capacity)
Parameters
capacity
intThe suggested starting size of this instance.
StringBuilder(int, int)
Initializes a new instance of the StringBuilder class that starts with a specified capacity and can grow to a specified maximum.
public StringBuilder(int capacity, int maxCapacity)
Parameters
capacity
intThe suggested starting size of the StringBuilder.
maxCapacity
intThe maximum number of characters the current string can contain.
StringBuilder(string)
Initializes a new instance of the StringBuilder class using the specified string.
public StringBuilder(string value)
Parameters
value
stringThe string used to initialize the value of the instance. If value is null, the new StringBuilder will contain the empty string (that is, it contains Empty).
StringBuilder(string, int)
Initializes a new instance of the StringBuilder class using the specified string and capacity.
public StringBuilder(string value, int capacity)
Parameters
value
stringThe string used to initialize the value of the instance. If value is null, the new StringBuilder will contain the empty string (that is, it contains Empty).
capacity
intThe suggested starting size of the StringBuilder.
StringBuilder(string, int, int, int)
Initializes a new instance of the StringBuilder class from the specified substring and capacity.
public StringBuilder(string value, int startIndex, int length, int capacity)
Parameters
value
stringThe string that contains the substring used to initialize the value of this instance. If value is null, the new StringBuilder will contain the empty string (that is, it contains Empty).
startIndex
intThe position within value where the substring begins.
length
intThe number of characters in the substring.
capacity
intThe suggested starting size of the StringBuilder.
Properties
Capacity
Gets or sets the maximum number of characters that can be contained in the memory allocated by the current instance.
public int Capacity { get; set; }
Property Value
- int
The maximum number of characters that can be contained in the memory allocated by the current instance. Its value can range from Length to MaxCapacity.
Exceptions
this[int]
Gets or sets the character at the specified character position in this instance.
public char this[int index] { get; set; }
Parameters
index
intThe position of the character.
Property Value
- char
The Unicode character at position index.
Length
Gets or sets the length of the current StringBuilder object.
public int Length { get; set; }
Property Value
- int
The length of this instance.
Exceptions
MaxCapacity
Gets the maximum capacity of this instance.
public int MaxCapacity { get; }
Property Value
- int
The maximum number of characters this instance can hold.
Methods
Append(bool)
Appends the string representation of a specified Boolean value to this instance.
public StringBuilder Append(bool value)
Parameters
value
boolThe Boolean value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(byte)
Appends the string representation of a specified 8-bit unsigned integer to this instance.
public StringBuilder Append(byte value)
Parameters
value
byteThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(char)
Appends the string representation of a specified Unicode character to this instance.
public StringBuilder Append(char value)
Parameters
value
charThe UTF-16-encoded code unit to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(char, int)
Appends a specified number of copies of the string representation of a Unicode character to this instance.
public StringBuilder Append(char value, int repeatCount)
Parameters
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(char[])
Appends the string representation of the Unicode characters in a specified array to this instance.
public StringBuilder Append(char[] value)
Parameters
value
char[]The array of characters to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(char[], int, int)
Appends the string representation of a specified subarray of Unicode characters to this instance
public StringBuilder Append(char[] value, int startIndex, int charCount)
Parameters
value
char[]A character array.
startIndex
intThe starting position in value.
charCount
intThe number of characters to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(double)
Appends the string representation of a specified double-precision floating-point number to this instance.
public StringBuilder Append(double value)
Parameters
value
doubleThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(short)
Appends the string representation of a specified 16-bit signed integer to this instance.
public StringBuilder Append(short value)
Parameters
value
shortThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(int)
Appends the string representation of a specified 32-bit signed integer to this instance.
public StringBuilder Append(int value)
Parameters
value
intThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(long)
Appends the string representation of a specified 64-bit unsigned integer to this instance.
public StringBuilder Append(long value)
Parameters
value
longThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(object)
Appends the string representation of a specified object to this instance.
public StringBuilder Append(object value)
Parameters
value
objectThe object to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(sbyte)
Appends the string representation of a specified 8-bit signed integer to this instance.
public StringBuilder Append(sbyte value)
Parameters
value
sbyteThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(float)
Appends the string representation of a specified double-precision floating-point number to this instance.
public StringBuilder Append(float value)
Parameters
value
floatThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(string)
Appends a copy of the specified string to this instance.
public StringBuilder Append(string value)
Parameters
value
stringThe string to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(string, int, int)
Appends a copy of a specified substring to this instance.
public StringBuilder Append(string value, int startIndex, int count)
Parameters
value
stringThe string that contains the substring to append.
startIndex
intThe starting position of the substring within value.
count
intThe number of characters in value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(ushort)
Appends the string representation of a specified 16-bit unsigned integer to this instance.
public StringBuilder Append(ushort value)
Parameters
value
ushortThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(uint)
Appends the string representation of a specified 32-bit unsigned integer to this instance.
public StringBuilder Append(uint value)
Parameters
value
uintThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
Append(ulong)
Appends the string representation of a specified 64-bit unsigned integer to this instance.
public StringBuilder Append(ulong value)
Parameters
value
ulongThe value to append.
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
AppendLine()
Appends the default line terminator to the end of the current StringBuilder object.
public StringBuilder AppendLine()
Returns
- StringBuilder
A reference to this instance after the append operation has completed.
AppendLine(string)
Appends a copy of the specified string followed by the default line terminator to the end of the current StringBuilder object.
public StringBuilder AppendLine(string str)
Parameters
str
stringA reference to this instance after the append operation has completed.
Returns
Clear()
Removes all characters from the current StringBuilder instance.
public StringBuilder Clear()
Returns
- StringBuilder
An object whose Length is 0 (zero).
Insert(int, char[], int, int)
Inserts the string representation of a specified subarray of Unicode characters into this instance at the specified character position.
public StringBuilder Insert(int index, char[] value, int startIndex, int charCount)
Parameters
index
intThe position in this instance where insertion begins.
value
char[]A character array.
startIndex
intThe starting index within value.
charCount
intThe number of characters to insert.
Returns
- StringBuilder
A reference to this instance after the insert operation has completed.
Insert(int, string, int)
Inserts one or more copies of a specified string into this instance at the specified character position.
public StringBuilder Insert(int index, string value, int count)
Parameters
index
intThe position in this instance where insertion begins.
value
stringThe string to insert.
count
intThe number of times to insert value.
Returns
- StringBuilder
A reference to this instance after insertion has completed.
Remove(int, int)
Removes the specified range of characters from this instance.
public StringBuilder Remove(int startIndex, int length)
Parameters
startIndex
intThe zero-based position in this instance where removal begins.
length
intThe number of characters to remove.
Returns
- StringBuilder
A reference to this instance after the excise operation has completed.
Replace(char, char)
Replaces all occurrences of a specified character in this instance with another specified character.
public StringBuilder Replace(char oldChar, char newChar)
Parameters
Returns
- StringBuilder
A reference to this instance with oldChar replaced by newChar.
Replace(char, char, int, int)
Replaces, within a substring of this instance, all occurrences of a specified character with another specified character.
public StringBuilder Replace(char oldChar, char newChar, int startIndex, int count)
Parameters
oldChar
charThe character to replace.
newChar
charThe character that replaces oldChar.
startIndex
intThe position in this instance where the substring begins.
count
intThe length of the substring.
Returns
- StringBuilder
A reference to this instance with oldChar replaced by newChar in the range from startIndex to startIndex + count -1.
Replace(string, string)
Replaces all occurrences of a specified string in this instance with another specified string.
public StringBuilder Replace(string oldValue, string newValue)
Parameters
Returns
- StringBuilder
A reference to this instance with all instances of oldValue replaced by newValue.
Replace(string, string, int, int)
Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.
public StringBuilder Replace(string oldValue, string newValue, int startIndex, int count)
Parameters
oldValue
stringThe string to replace.
newValue
stringThe string that replaces oldValue, or null.
startIndex
intThe position in this instance where the substring begins.
count
intThe length of the substring.
Returns
- StringBuilder
A reference to this instance with all instances of oldValue replaced by newValue in the range from startIndex to startIndex + count - 1.
ToString()
Converts the value of this instance to a String. (Overrides Object.ToString().)
public override string ToString()
Returns
- string
A string whose value is the same as this instance.
ToString(int, int)
Converts the value of a substring of this instance to a String.
public string ToString(int startIndex, int length)
Parameters
startIndex
intThe starting position of the substring in this instance.
length
intThe length of the substring.
Returns
- string
A string whose value is the same as the specified substring of this instance.