Table of Contents

Class StringBuilder

Namespace
System.Text
Assembly
nanoFramework.System.Text.dll

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 int

The 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 int

The suggested starting size of the StringBuilder.

maxCapacity int

The 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 string

The 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 string

The 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 int

The 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 string

The 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 int

The position within value where the substring begins.

length int

The number of characters in the substring.

capacity int

The 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

ArgumentOutOfRangeException

this[int]

Gets or sets the character at the specified character position in this instance.

public char this[int index] { get; set; }

Parameters

index int

The 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

ArgumentOutOfRangeException

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 bool

The 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 byte

The 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 char

The 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

value char

The character to append.

repeatCount int

The number of times to append value.

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 int

The starting position in value.

charCount int

The 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 double

The 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 short

The 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 int

The 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 long

The 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 object

The 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 sbyte

The 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 float

The 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 string

The 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 string

The string that contains the substring to append.

startIndex int

The starting position of the substring within value.

count int

The 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 ushort

The 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 uint

The 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 ulong

The 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 string

A reference to this instance after the append operation has completed.

Returns

StringBuilder

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 int

The position in this instance where insertion begins.

value char[]

A character array.

startIndex int

The starting index within value.

charCount int

The 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 int

The position in this instance where insertion begins.

value string

The string to insert.

count int

The 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 int

The zero-based position in this instance where removal begins.

length int

The 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

oldChar char

The character to replace.

newChar char

The character that replaces oldChar.

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 char

The character to replace.

newChar char

The character that replaces oldChar.

startIndex int

The position in this instance where the substring begins.

count int

The 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

oldValue string

The string to replace.

newValue string

The string that replaces oldValue, or null.

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 string

The string to replace.

newValue string

The string that replaces oldValue, or null.

startIndex int

The position in this instance where the substring begins.

count int

The 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 int

The starting position of the substring in this instance.

length int

The length of the substring.

Returns

string

A string whose value is the same as the specified substring of this instance.