Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Text.​StringBuilder
Assembly: System.Runtime
Inheritance: object → StringBuilder
Implemented Interfaces
Represents a mutable string of characters. This class cannot be inherited.
Properties
public
int
Capacity
Gets or sets the maximum number of characters that can be contained in the memory allocated by the current instance.
public
char
Chars
public
int
Length
Gets or sets the length of the current <see cref="T:System.Text.StringBuilder" /> object.
public
int
MaxCapacity
Gets the maximum capacity of this instance.
Methods
public
StringBuilder
Append​(bool value)
Appends the string representation of a specified Boolean value to this instance.
Returns A reference to this instance after the append operation has completed.
value
The Boolean value to append.
public
StringBuilder
Append​(byte value)
Appends the string representation of a specified 8-bit unsigned integer to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(char value)
Appends the string representation of a specified <see cref="T:System.Char" /> object to this instance.
Returns A reference to this instance after the append operation has completed.
value
The UTF-16-encoded code unit to append.
public
StringBuilder
Append​(Char* value,
int valueCount)
Appends an array of Unicode characters starting at a specified address to this instance.
Returns A reference to this instance after the append operation has completed.
value
A pointer to an array of characters.
valueCount
The number of characters in the array.
public
StringBuilder
Append​(char value,
int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this instance.
Returns A reference to this instance after the append operation has completed.
value
The character to append.
repeatCount
The number of times to append <paramref name="value" /> .
public
StringBuilder
Append​(char[] value)
Appends the string representation of the Unicode characters in a specified array to this instance.
Returns A reference to this instance after the append operation has completed.
value
The array of characters to append.
public
StringBuilder
Append​(char[] value,
int startIndex,
int charCount)
Appends the string representation of a specified subarray of Unicode characters to this instance.
Returns A reference to this instance after the append operation has completed.
value
A character array.
startIndex
The starting position in <paramref name="value" /> .
charCount
The number of characters to append.
public
StringBuilder
Append​(decimal value)
Appends the string representation of a specified decimal number to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(double value)
Appends the string representation of a specified double-precision floating-point number to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(IFormatProvider? provider,
AppendInterpolatedStringHandler& handler)
public
StringBuilder
Append​(short value)
Appends the string representation of a specified 16-bit signed integer to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(int value)
Appends the string representation of a specified 32-bit signed integer to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(long value)
Appends the string representation of a specified 64-bit signed integer to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(object value)
Appends the string representation of a specified object to this instance.
Returns A reference to this instance after the append operation has completed.
value
The object to append.
public
StringBuilder
Append​(ReadOnlyMemory<​char> value)
Appends the string representation of a specified read-only character memory region to this instance.
Returns A reference to this instance after the append operation is completed.
value
The read-only character memory region to append.
public
StringBuilder
Append​(ReadOnlySpan<​char> value)
Appends the string representation of a specified read-only character span to this instance.
Returns A reference to this instance after the append operation is completed.
value
The read-only character span to append.
public
StringBuilder
Append​(sbyte value)
Appends the string representation of a specified 8-bit signed integer to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(Single value)
Appends the string representation of a specified single-precision floating-point number to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(string value)
Appends a copy of the specified string to this instance.
Returns A reference to this instance after the append operation has completed.
value
The string to append.
public
StringBuilder
Append​(string value,
int startIndex,
int count)
Appends a copy of a specified substring to this instance.
Returns A reference to this instance after the append operation has completed.
value
The string that contains the substring to append.
startIndex
The starting position of the substring within <paramref name="value" /> .
count
The number of characters in <paramref name="value" /> to append.
public
StringBuilder
Append​(StringBuilder? value)
Appends the string representation of a specified string builder to this instance.
Returns A reference to this instance after the append operation is completed.
value
The string builder to append.
public
StringBuilder
Append​(StringBuilder? value,
int startIndex,
int count)
Appends a copy of a substring within a specified string builder to this instance.
Returns A reference to this instance after the append operation has completed.
value
The string builder that contains the substring to append.
startIndex
The starting position of the substring within <paramref name="value" /> .
count
The number of characters in <paramref name="value" /> to append.
public
StringBuilder
Append​(ushort value)
Appends the string representation of a specified 16-bit unsigned integer to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(uint value)
Appends the string representation of a specified 32-bit unsigned integer to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
Append​(ulong value)
Appends the string representation of a specified 64-bit unsigned integer to this instance.
Returns A reference to this instance after the append operation has completed.
value
The value to append.
public
StringBuilder
AppendFormat​(IFormatProvider? provider,
string format,
object arg0)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a single argument using a specified format provider.
Returns A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of <paramref name="format" /> in which any format specification is replaced by the string representation of <paramref name="arg0" /> .
provider
An object that supplies culture-specific formatting information.
format
A composite format string.
arg0
The object to format.
public
StringBuilder
AppendFormat​(IFormatProvider provider,
string format,
object arg0,
object arg1)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of two arguments using a specified format provider.
Returns A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of <paramref name="format" /> where any format specification is replaced by the string representation of the corresponding object argument.
provider
An object that supplies culture-specific formatting information.
format
A composite format string.
arg0
The first object to format.
arg1
The second object to format.
public
StringBuilder
AppendFormat​(IFormatProvider provider,
string format,
object arg0,
object arg1,
object arg2)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of three arguments using a specified format provider.
Returns A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of <paramref name="format" /> where any format specification is replaced by the string representation of the corresponding object argument.
provider
An object that supplies culture-specific formatting information.
format
A composite format string.
arg0
The first object to format.
arg1
The second object to format.
arg2
The third object to format.
public
StringBuilder
AppendFormat​(IFormatProvider? provider,
string format,
object[] args)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array using a specified format provider.
Returns A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of <paramref name="format" /> where any format specification is replaced by the string representation of the corresponding object argument.
provider
An object that supplies culture-specific formatting information.
format
A composite format string.
args
An array of objects to format.
public
StringBuilder
AppendFormat​(IFormatProvider? provider,
string format,
ReadOnlySpan<​object> args)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance.
Each format item is replaced by the string representation of a corresponding argument in a parameter span using a specified format provider.
Returns A reference to this instance after the append operation has completed.
provider
An object that supplies culture-specific formatting information.
format
A composite format string.
args
A span of objects to format.
public
StringBuilder
AppendFormat​(IFormatProvider? provider,
CompositeFormat format,
object[] args)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance.
Each format item is replaced by the string representation of any of the arguments using a specified format provider.
Returns A reference to this instance after the append operation has completed.
provider
An object that supplies culture-specific formatting information.
format
A <see cref="T:System.Text.CompositeFormat" /> .
args
An array of objects to format.
public
StringBuilder
AppendFormat​(IFormatProvider? provider,
CompositeFormat format,
ReadOnlySpan<​object> args)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance.
Each format item is replaced by the string representation of any of the arguments using a specified format provider.
Returns A reference to this instance after the append operation has completed.
provider
An object that supplies culture-specific formatting information.
format
A <see cref="T:System.Text.CompositeFormat" /> .
args
A span of objects to format.
public
StringBuilder
AppendFormat​(string format,
object arg0)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a single argument.
Returns A reference to this instance with <paramref name="format" /> appended. Each format item in <paramref name="format" /> is replaced by the string representation of <paramref name="arg0" /> .
format
A composite format string.
arg0
An object to format.
public
StringBuilder
AppendFormat​(string format,
object arg0,
object arg1)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of two arguments.
Returns A reference to this instance with <paramref name="format" /> appended. Each format item in <paramref name="format" /> is replaced by the string representation of the corresponding object argument.
format
A composite format string.
arg0
The first object to format.
arg1
The second object to format.
public
StringBuilder
AppendFormat​(string format,
object arg0,
object arg1,
object arg2)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of three arguments.
Returns A reference to this instance with <paramref name="format" /> appended. Each format item in <paramref name="format" /> is replaced by the string representation of the corresponding object argument.
format
A composite format string.
arg0
The first object to format.
arg1
The second object to format.
arg2
The third object to format.
public
StringBuilder
AppendFormat​(string format,
object[] args)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array.
Returns A reference to this instance with <paramref name="format" /> appended. Each format item in <paramref name="format" /> is replaced by the string representation of the corresponding object argument.
format
A composite format string.
args
An array of objects to format.
public
StringBuilder
AppendFormat​(string format,
ReadOnlySpan<​object> args)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance.
Each format item is replaced by the string representation of a corresponding argument in a parameter span.
Returns A reference to this instance after the append operation has completed.
format
A composite format string.
args
A span of objects to format.
public
StringBuilder
AppendFormat​(IFormatProvider? provider,
CompositeFormat format,
TArg0 arg0)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance.
Each format item is replaced by the string representation of any of the arguments using a specified format provider.
Returns A reference to this instance after the append operation has completed.
provider
An object that supplies culture-specific formatting information.
format
A <see cref="T:System.Text.CompositeFormat" /> .
arg0
The first object to format.
public
StringBuilder
AppendFormat​(IFormatProvider? provider,
CompositeFormat format,
TArg0 arg0,
TArg1 arg1)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance.
Each format item is replaced by the string representation of any of the arguments using a specified format provider.
Returns A reference to this instance after the append operation has completed.
provider
An object that supplies culture-specific formatting information.
format
A <see cref="T:System.Text.CompositeFormat" /> .
arg0
The first object to format.
arg1
The second object to format.
public
StringBuilder
AppendFormat​(IFormatProvider? provider,
CompositeFormat format,
TArg0 arg0,
TArg1 arg1,
TArg2 arg2)
Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance.
Each format item is replaced by the string representation of any of the arguments using a specified format provider.
Returns A reference to this instance after the append operation has completed.
provider
An object that supplies culture-specific formatting information.
format
A <see cref="T:System.Text.CompositeFormat" /> .
arg0
The first object to format.
arg1
The second object to format.
arg2
The third object to format.
public
StringBuilder
AppendJoin​(char separator,
object[] values)
Concatenates the string representations of the elements in the provided array of objects, using the specified char separator between each member, then appends the result to the current instance of the string builder.
Returns A reference to this instance after the append operation has completed.
separator
The character to use as a separator. <paramref name="separator" /> is included in the joined strings only if <paramref name="values" /> has more than one element.
values
An array that contains the strings to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(char separator,
string[] values)
Concatenates the strings of the provided array, using the specified char separator between each string, then appends the result to the current instance of the string builder.
Returns A reference to this instance after the append operation has completed.
separator
The character to use as a separator. <paramref name="separator" /> is included in the joined strings only if <paramref name="values" /> has more than one element.
values
An array that contains the strings to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(char separator,
ReadOnlySpan<​object> values)
Concatenates the string representations of the elements in the provided span of objects, using the specified char separator between each member, then appends the result to the current instance of the string builder.
Returns A reference to this instance after the append operation has completed.
separator
The character to use as a separator. <paramref name="separator" /> is included in the joined strings only if <paramref name="values" /> has more than one element.
values
A span that contains the strings to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(char separator,
ReadOnlySpan<​string> values)
Concatenates the strings of the provided span, using the specified char separator between each string, then appends the result to the current instance of the string builder.
Returns A reference to this instance after the append operation has completed.
separator
The character to use as a separator. <paramref name="separator" /> is included in the joined strings only if <paramref name="values" /> has more than one element.
values
A span that contains the strings to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(string separator,
object[] values)
Concatenates the string representations of the elements in the provided array of objects, using the specified separator between each member, then appends the result to the current instance of the string builder.
Returns A reference to this instance after the append operation has completed.
separator
The string to use as a separator. <paramref name="separator" /> is included in the joined strings only if <paramref name="values" /> has more than one element.
values
An array that contains the strings to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(string separator,
string[] values)
Concatenates the strings of the provided array, using the specified separator between each string, then appends the result to the current instance of the string builder.
Returns A reference to this instance after the append operation has completed.
separator
The string to use as a separator. <paramref name="separator" /> is included in the joined strings only if <paramref name="values" /> has more than one element.
values
An array that contains the strings to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(string separator,
ReadOnlySpan<​object> values)
Concatenates the string representations of the elements in the provided span of objects, using the specified separator between each member, then appends the result to the current instance of the string builder.
Returns A reference to this instance after the append operation has completed.
separator
The string to use as a separator. <paramref name="separator" /> is included in the joined strings only if <paramref name="values" /> has more than one element.
values
A span that contains the strings to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(string separator,
ReadOnlySpan<​string> values)
Concatenates the strings of the provided span, using the specified separator between each string, then appends the result to the current instance of the string builder.
Returns A reference to this instance after the append operation has completed.
separator
The string to use as a separator. <paramref name="separator" /> is included in the joined strings only if <paramref name="values" /> has more than one element.
values
A span that contains the strings to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(char separator,
Collections.​Generic.​IEnumerable<​T> values)
Concatenates and appends the members of a collection, using the specified char separator between each member.
Returns A reference to this instance after the append operation has completed.
separator
The character to use as a separator. <paramref name="separator" /> is included in the concatenated and appended strings only if <paramref name="values" /> has more than one element.
values
A collection that contains the objects to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendJoin​(string separator,
Collections.​Generic.​IEnumerable<​T> values)
Concatenates and appends the members of a collection, using the specified separator between each member.
Returns A reference to this instance after the append operation has completed.
separator
The string to use as a separator. <paramref name="separator" /> is included in the concatenated and appended strings only if <paramref name="values" /> has more than one element.
values
A collection that contains the objects to concatenate and append to the current instance of the string builder.
public
StringBuilder
AppendLine​()
Appends the default line terminator to the end of the current <see cref="T:System.Text.StringBuilder" /> object.
Returns A reference to this instance after the append operation has completed.
public
StringBuilder
AppendLine​(IFormatProvider? provider,
AppendInterpolatedStringHandler& handler)
public
StringBuilder
AppendLine​(string value)
Appends a copy of the specified string followed by the default line terminator to the end of the current <see cref="T:System.Text.StringBuilder" /> object.
Returns A reference to this instance after the append operation has completed.
value
The string to append.
public
StringBuilder
Clear​()
Removes all characters from the current <see cref="T:System.Text.StringBuilder" /> instance.
Returns An object whose <see cref="P:System.Text.StringBuilder.Length" /> is 0 (zero).
public
void
CopyTo​(int sourceIndex,
char[] destination,
int destinationIndex,
int count)
Copies the characters from a specified segment of this instance to a specified segment of a destination <see cref="T:System.Char" /> array.
sourceIndex
The starting position in this instance where characters will be copied from. The index is zero-based.
destination
The array where characters will be copied.
destinationIndex
The starting position in <paramref name="destination" /> where characters will be copied. The index is zero-based.
count
The number of characters to be copied.
public
void
CopyTo​(int sourceIndex,
Span<​char> destination,
int count)
Copies the characters from a specified segment of this instance to a destination <see cref="T:System.Char" /> span.
sourceIndex
The starting position in this instance where characters will be copied from. The index is zero-based.
destination
The writable span where characters will be copied.
count
The number of characters to be copied.
public
int
EnsureCapacity​(int capacity)
Ensures that the capacity of this instance of <see cref="T:System.Text.StringBuilder" /> is at least the specified value.
Returns The new capacity of this instance.
capacity
The minimum capacity to ensure.
public
bool
Equals​(ReadOnlySpan<​char> span)
Returns a value indicating whether the characters in this instance are equal to the characters in a specified read-only character span.
Returns <see langword="true" /> if the characters in this instance and <paramref name="span" /> are the same; otherwise, <see langword="false" /> .
span
The character span to compare with the current instance.
public
bool
Equals​(StringBuilder sb)
Returns a value indicating whether this instance is equal to a specified object.
Returns <see langword="true" /> if this instance and <paramref name="sb" /> have equal string, <see cref="P:System.Text.StringBuilder.Capacity" /> , and <see cref="P:System.Text.StringBuilder.MaxCapacity" /> values; otherwise, <see langword="false" /> .
sb
An object to compare with this instance, or <see langword="null" /> .
public
ChunkEnumerator
GetChunks​()
Returns an object that can be used to iterate through the chunks of characters represented in a <see langword="ReadOnlyMemory<Char>" /> created from this <see cref="T:System.Text.StringBuilder" /> instance.
Returns An enumerator for the chunks in the <see langword="ReadOnlyMemory<Char>" /> .
public
StringBuilder
Insert​(int index,
bool value)
Inserts the string representation of a Boolean value into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
byte value)
Inserts the string representation of a specified 8-bit unsigned integer into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
char value)
Inserts the string representation of a specified Unicode character into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
char[] value)
Inserts the string representation of a specified array of Unicode characters into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The character array to insert.
public
StringBuilder
Insert​(int index,
char[] value,
int startIndex,
int charCount)
Inserts the string representation of a specified subarray of Unicode characters into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
A character array.
startIndex
The starting index within <paramref name="value" /> .
charCount
The number of characters to insert.
public
StringBuilder
Insert​(int index,
decimal value)
Inserts the string representation of a decimal number into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
double value)
Inserts the string representation of a double-precision floating-point number into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
short value)
Inserts the string representation of a specified 16-bit signed integer into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
int value)
Inserts the string representation of a specified 32-bit signed integer into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
long value)
Inserts the string representation of a 64-bit signed integer into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
object value)
Inserts the string representation of an object into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The object to insert, or <see langword="null" /> .
public
StringBuilder
Insert​(int index,
ReadOnlySpan<​char> value)
Inserts the sequence of characters into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The character span to insert.
public
StringBuilder
Insert​(int index,
sbyte value)
Inserts the string representation of a specified 8-bit signed integer into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
Single value)
Inserts the string representation of a single-precision floating point number into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
string value)
Inserts a string into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The string to insert.
public
StringBuilder
Insert​(int index,
string value,
int count)
Inserts one or more copies of a specified string into this instance at the specified character position.
Returns A reference to this instance after insertion has completed.
index
The position in this instance where insertion begins.
value
The string to insert.
count
The number of times to insert <paramref name="value" /> .
public
StringBuilder
Insert​(int index,
ushort value)
Inserts the string representation of a 16-bit unsigned integer into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
uint value)
Inserts the string representation of a 32-bit unsigned integer into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Insert​(int index,
ulong value)
Inserts the string representation of a 64-bit unsigned integer into this instance at the specified character position.
Returns A reference to this instance after the insert operation has completed.
index
The position in this instance where insertion begins.
value
The value to insert.
public
StringBuilder
Remove​(int startIndex,
int length)
Removes the specified range of characters from this instance.
Returns A reference to this instance after the excise operation has completed.
startIndex
The zero-based position in this instance where removal begins.
length
The number of characters to remove.
public
StringBuilder
Replace​(char oldChar,
char newChar)
Replaces all occurrences of a specified character in this instance with another specified character.
Returns A reference to this instance with <paramref name="oldChar" /> replaced by <paramref name="newChar" /> .
oldChar
The character to replace.
newChar
The character that replaces <paramref name="oldChar" /> .
public
StringBuilder
Replace​(char oldChar,
char newChar,
int startIndex,
int count)
Replaces, within a substring of this instance, all occurrences of a specified character with another specified character.
Returns A reference to this instance with <paramref name="oldChar" /> replaced by <paramref name="newChar" /> in the range from <paramref name="startIndex" /> to <paramref name="startIndex" /> + <paramref name="count" /> -1.
oldChar
The character to replace.
newChar
The character that replaces <paramref name="oldChar" /> .
startIndex
The position in this instance where the substring begins.
count
The length of the substring.
public
StringBuilder
Replace​(ReadOnlySpan<​char> oldValue,
ReadOnlySpan<​char> newValue)
Replaces all instances of one read-only character span with another in this builder.
Returns A reference to this instance with <paramref name="oldValue" /> replaced by <paramref name="newValue" /> .
oldValue
The read-only character span to replace.
newValue
The read-only character span to replace <paramref name="oldValue" /> with.
public
StringBuilder
Replace​(ReadOnlySpan<​char> oldValue,
ReadOnlySpan<​char> newValue,
int startIndex,
int count)
Replaces all instances of one read-only character span with another in part of this builder.
Returns A reference to this instance with <paramref name="oldValue" /> replaced by <paramref name="newValue" /> .
oldValue
The read-only character span to replace.
newValue
The read-only character span to replace <paramref name="oldValue" /> with.
startIndex
The index to start in this builder.
count
The number of characters to read in this builder.
public
StringBuilder
Replace​(string oldValue,
string newValue)
Replaces all occurrences of a specified string in this instance with another specified string.
Returns A reference to this instance with all instances of <paramref name="oldValue" /> replaced by <paramref name="newValue" /> .
oldValue
The string to replace.
newValue
The string that replaces <paramref name="oldValue" /> , or <see langword="null" /> .
public
StringBuilder
Replace​(string oldValue,
string newValue,
int startIndex,
int count)
Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.
Returns A reference to this instance with all instances of <paramref name="oldValue" /> replaced by <paramref name="newValue" /> in the range from <paramref name="startIndex" /> to <paramref name="startIndex" /> + <paramref name="count" /> - 1.
oldValue
The string to replace.
newValue
The string that replaces <paramref name="oldValue" /> , or <see langword="null" /> .
startIndex
The position in this instance where the substring begins.
count
The length of the substring.
public
string
ToString​()
Converts the value of this instance to a <see cref="T:System.String" /> .
Returns A string whose value is the same as this instance.
public
string
ToString​(int startIndex,
int length)
Converts the value of a substring of this instance to a <see cref="T:System.String" /> .
Returns A string whose value is the same as the specified substring of this instance.
startIndex
The starting position of the substring in this instance.
length
The length of the substring.
public
bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj
The object to compare with the current object.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public
Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .