Table of Contents

Struct ValueStringBuilder

Namespace
LinkDotNet.StringBuilder
Assembly
LinkDotNet.StringBuilder.dll

A string builder which minimizes as many heap allocations as possible.

public ref struct ValueStringBuilder : IDisposable
Implements
Inherited Members
Extension Methods

Remarks

This is a ref struct which has certain limitations. You can only store it in a local variable or another ref struct.

You should dispose it after use to ensure the rented buffer is returned to the array pool.

Constructors

ValueStringBuilder()

Initializes a new instance of the ValueStringBuilder struct using a rented buffer of capacity 32.

public ValueStringBuilder()

ValueStringBuilder(int)

Initializes a new instance of the ValueStringBuilder struct.

public ValueStringBuilder(int initialCapacity)

Parameters

initialCapacity int

The initial capacity that will be allocated for this instance.

ValueStringBuilder(scoped ReadOnlySpan<char>)

Initializes a new instance of the ValueStringBuilder struct.

public ValueStringBuilder(scoped ReadOnlySpan<char> initialText)

Parameters

initialText ReadOnlySpan<char>

The initial text used to initialize this instance.

ValueStringBuilder(Span<char>)

Initializes a new instance of the ValueStringBuilder struct.

public ValueStringBuilder(Span<char> initialBuffer)

Parameters

initialBuffer Span<char>

Initial buffer for the string builder to begin with.

Properties

Capacity

Gets the current maximum capacity before the span must be resized.

public readonly int Capacity { get; }

Property Value

int

The current maximum capacity before the span must be resized.

IsEmpty

Gets a value indicating whether the builder's length is 0.

public readonly bool IsEmpty { get; }

Property Value

bool

true if the builder is empty; otherwise, false.

this[int]

Returns the character at the given index or throws an IndexOutOfRangeException if the index is bigger than the string.

public readonly ref char this[int index] { get; }

Parameters

index int

Character position to be retrieved.

Property Value

char

Length

Gets the current length of the represented string.

public readonly int Length { get; }

Property Value

int

The current length of the represented string.

Methods

Append(ref AppendInterpolatedStringHandler)

Appends an interpolated string to the builder.

public void Append(ref ValueStringBuilder.AppendInterpolatedStringHandler handler)

Parameters

handler ValueStringBuilder.AppendInterpolatedStringHandler

The interpolated string handler.

Append(bool)

Appends the string representation of the boolean.

public void Append(bool value)

Parameters

value bool

Bool value to add.

Append(char)

Appends a single character.

public void Append(char value)

Parameters

value char

Character to add.

Append(char*, int)

Appends a character buffer.

public void Append(char* value, int length)

Parameters

value char*

The pointer to the start of the buffer.

length int

The number of characters in the buffer.

Append(ReadOnlyMemory<char>)

Appends a slice of memory.

public void Append(ReadOnlyMemory<char> memory)

Parameters

memory ReadOnlyMemory<char>

The memory to add.

Append(scoped ReadOnlySpan<char>)

Appends a string.

public void Append(scoped ReadOnlySpan<char> str)

Parameters

str ReadOnlySpan<char>

String to be added to this builder.

Append(string?)

Appends a string.

public void Append(string? value)

Parameters

value string

The string to be added to this builder.

Append(Rune)

Appends a single rune to the string builder.

public void Append(Rune value)

Parameters

value Rune

Rune to add.

AppendFormat<T>(scoped ReadOnlySpan<char>, T)

Appends the format string to the given ValueStringBuilder instance.

public void AppendFormat<T>(scoped ReadOnlySpan<char> format, T arg)

Parameters

format ReadOnlySpan<char>

Format string.

arg T

Argument for {0}.

Type Parameters

T

Any type.

Remarks

The current version does not allow for a custom format.
So: 
AppendFormat("{0:00}")

is not allowed and will result in an exception.

AppendFormat<T1, T2>(scoped ReadOnlySpan<char>, T1, T2)

Appends the format string to the given ValueStringBuilder instance.

public void AppendFormat<T1, T2>(scoped ReadOnlySpan<char> format, T1 arg1, T2 arg2)

Parameters

format ReadOnlySpan<char>

Format string.

arg1 T1

Argument for {0}.

arg2 T2

Argument for {1}.

Type Parameters

T1

Any type for arg1.

T2

Any type for arg2.

Remarks

The current version does not allow for a custom format.
So: 
AppendFormat("{0:00}")

is not allowed and will result in an exception.

AppendFormat<T1, T2, T3>(scoped ReadOnlySpan<char>, T1, T2, T3)

Appends the format string to the given ValueStringBuilder instance.

public void AppendFormat<T1, T2, T3>(scoped ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3)

Parameters

format ReadOnlySpan<char>

Format string.

arg1 T1

Argument for {0}.

arg2 T2

Argument for {1}.

arg3 T3

Argument for {2}.

Type Parameters

T1

Any type for arg1.

T2

Any type for arg2.

T3

Any type for arg3.

Remarks

The current version does not allow for a custom format.
So: 
AppendFormat("{0:00}")

is not allowed and will result in an exception.

AppendFormat<T1, T2, T3, T4>(scoped ReadOnlySpan<char>, T1, T2, T3, T4)

Appends the format string to the given ValueStringBuilder instance.

public void AppendFormat<T1, T2, T3, T4>(scoped ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4)

Parameters

format ReadOnlySpan<char>

Format string.

arg1 T1

Argument for {0}.

arg2 T2

Argument for {1}.

arg3 T3

Argument for {2}.

arg4 T4

Argument for {3}.

Type Parameters

T1

Any type for arg1.

T2

Any type for arg2.

T3

Any type for arg3.

T4

Any type for arg4.

Remarks

The current version does not allow for a custom format.
So: 
AppendFormat("{0:00}")

is not allowed and will result in an exception.

AppendFormat<T1, T2, T3, T4, T5>(scoped ReadOnlySpan<char>, T1, T2, T3, T4, T5)

Appends the format string to the given ValueStringBuilder instance.

public void AppendFormat<T1, T2, T3, T4, T5>(scoped ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)

Parameters

format ReadOnlySpan<char>

Format string.

arg1 T1

Argument for {0}.

arg2 T2

Argument for {1}.

arg3 T3

Argument for {2}.

arg4 T4

Argument for {3}.

arg5 T5

Argument for {4}.

Type Parameters

T1

Any type for arg1.

T2

Any type for arg2.

T3

Any type for arg3.

T4

Any type for arg4.

T5

Any type for arg5.

Remarks

The current version does not allow for a custom format.
So: 
AppendFormat("{0:00}")

is not allowed and will result in an exception.

AppendJoin(char, IEnumerable<string?>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin(char separator, IEnumerable<string?> values)

Parameters

separator char

Character used as separator between the entries.

values IEnumerable<string>

Enumerable of strings to be concatenated.

AppendJoin(char, scoped ReadOnlySpan<string?>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin(char separator, scoped ReadOnlySpan<string?> values)

Parameters

separator char

Character used as separator between the entries.

values ReadOnlySpan<string>

Enumerable of strings to be concatenated.

AppendJoin(ReadOnlySpan<char>, IEnumerable<string?>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin(ReadOnlySpan<char> separator, IEnumerable<string?> values)

Parameters

separator ReadOnlySpan<char>

String used as separator between the entries.

values IEnumerable<string>

Enumerable of strings to be concatenated.

AppendJoin(ReadOnlySpan<char>, scoped ReadOnlySpan<string?>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin(ReadOnlySpan<char> separator, scoped ReadOnlySpan<string?> values)

Parameters

separator ReadOnlySpan<char>

String used as separator between the entries.

values ReadOnlySpan<string>

Enumerable of strings to be concatenated.

AppendJoin(Rune, IEnumerable<string?>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin(Rune separator, IEnumerable<string?> values)

Parameters

separator Rune

Rune used as separator between the entries.

values IEnumerable<string>

Enumerable of strings to be concatenated.

AppendJoin<T>(char, IEnumerable<T>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin<T>(char separator, IEnumerable<T> values)

Parameters

separator char

Character used as separator between the entries.

values IEnumerable<T>

Enumerable to be concatenated.

Type Parameters

T

Type of the given enumerable.

AppendJoin<T>(char, scoped ReadOnlySpan<T>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin<T>(char separator, scoped ReadOnlySpan<T> values)

Parameters

separator char

Character used as separator between the entries.

values ReadOnlySpan<T>

Enumerable to be concatenated.

Type Parameters

T

Type of the given enumerable.

AppendJoin<T>(scoped ReadOnlySpan<char>, IEnumerable<T>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin<T>(scoped ReadOnlySpan<char> separator, IEnumerable<T> values)

Parameters

separator ReadOnlySpan<char>

String used as separator between the entries.

values IEnumerable<T>

Enumerable to be concatenated.

Type Parameters

T

Type of the given enumerable.

AppendJoin<T>(scoped ReadOnlySpan<char>, ReadOnlySpan<T>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin<T>(scoped ReadOnlySpan<char> separator, ReadOnlySpan<T> values)

Parameters

separator ReadOnlySpan<char>

String used as separator between the entries.

values ReadOnlySpan<T>

Enumerable to be concatenated.

Type Parameters

T

Type of the given enumerable.

AppendJoin<T>(Rune, IEnumerable<T>)

Concatenates and appends all values with the given separator between each entry at the end of the string.

public void AppendJoin<T>(Rune separator, IEnumerable<T> values)

Parameters

separator Rune

Rune used as separator between the entries.

values IEnumerable<T>

Enumerable to be concatenated.

Type Parameters

T

Type of the given enumerable.

AppendLine()

Appends NewLine.

public void AppendLine()

AppendLine(ref AppendInterpolatedStringHandler)

Appends an interpolated string followed by a new line to the builder.

public void AppendLine(ref ValueStringBuilder.AppendInterpolatedStringHandler handler)

Parameters

handler ValueStringBuilder.AppendInterpolatedStringHandler

The interpolated string handler.

AppendLine(scoped ReadOnlySpan<char>)

public void AppendLine(scoped ReadOnlySpan<char> str)

Parameters

str ReadOnlySpan<char>

String to be added to this builder.

AppendLine(string?)

Calls Append(string?) and appends NewLine.

public void AppendLine(string? value)

Parameters

value string

The string to be added to this builder.

AppendPadLeft(scoped ReadOnlySpan<char>, int, char)

Appends the source string padded on the left with the given character to reach the specified total width.

public void AppendPadLeft(scoped ReadOnlySpan<char> source, int sourceTotalWidth, char paddingChar = ' ')

Parameters

source ReadOnlySpan<char>

The source string to pad and append.

sourceTotalWidth int

Total width of the padded string.

paddingChar char

Character to pad the string with. Defaults to space.

AppendPadRight(scoped ReadOnlySpan<char>, int, char)

Appends the source string padded on the right with the given character to reach the specified total width.

public void AppendPadRight(scoped ReadOnlySpan<char> source, int sourceTotalWidth, char paddingChar = ' ')

Parameters

source ReadOnlySpan<char>

The source string to pad and append.

sourceTotalWidth int

Total width of the padded string.

paddingChar char

Character to pad the string with. Defaults to space.

AppendSpan(int)

Appends a span of the given length, which can be written to later.

public Span<char> AppendSpan(int length)

Parameters

length int

Integer representing the number of characters to be appended.

Returns

Span<char>

A span with the characters appended.

Append<T>(T, scoped ReadOnlySpan<char>, int, IFormatProvider?)

Appends the string representation of the value.

public void Append<T>(T value, scoped ReadOnlySpan<char> format = default, int bufferSize = 36, IFormatProvider? formatProvider = null) where T : ISpanFormattable

Parameters

value T

Formattable span to add.

format ReadOnlySpan<char>

Optional formatter. If not provided the default of the given instance is taken.

bufferSize int

Size of the buffer allocated. If you have a custom type that implements ISpanFormattable that requires more space than the default (36 characters), adjust the value.

formatProvider IFormatProvider

Optional format provider.

Type Parameters

T

Any ISpanFormattable.

AsSpan()

Returns the string as an ReadOnlySpan<T>.

public readonly ReadOnlySpan<char> AsSpan()

Returns

ReadOnlySpan<char>

The filled array as ReadOnlySpan<T>.

AsSpan(int)

Returns the string as an ReadOnlySpan<T>.

public readonly ReadOnlySpan<char> AsSpan(int startIndex)

Parameters

startIndex int

The starting position of the substring in this instance.

Returns

ReadOnlySpan<char>

The filled array as ReadOnlySpan<T>.

AsSpan(int, int)

Returns the string as an ReadOnlySpan<T>.

public readonly ReadOnlySpan<char> AsSpan(int startIndex, int length)

Parameters

startIndex int

The starting position of the substring in this instance.

length int

The length of the substring.

Returns

ReadOnlySpan<char>

The filled array as ReadOnlySpan<T>.

AsSpan(Range)

Returns the string as an ReadOnlySpan<T>.

public readonly ReadOnlySpan<char> AsSpan(Range range)

Parameters

range Range

The range to be retrieved.

Returns

ReadOnlySpan<char>

The filled array as ReadOnlySpan<T>.

Clear()

Clears the internal representation of the string.

public void Clear()

Remarks

This will not enforce some re-allocation or shrinking of the internal buffer. The size stays the same.

Concat<T>(params ReadOnlySpan<T>)

Concatenates the string representation of multiple objects together.

public static string Concat<T>(params ReadOnlySpan<T> values)

Parameters

values ReadOnlySpan<T>

Values to be concatenated.

Returns

string

The concatenated string, or an empty string if values is empty.

Type Parameters

T

Any type for values that can be converted to string.

Concat<T1>(T1)

Creates the string representation of an object.

public static string Concat<T1>(T1 arg1)

Parameters

arg1 T1

First value to be concatenated.

Returns

string

The string representation of the object.

Type Parameters

T1

Any type for arg1 that can be converted to string.

Concat<T1, T2>(T1, T2)

Concatenates the string representation of two objects together.

public static string Concat<T1, T2>(T1 arg1, T2 arg2)

Parameters

arg1 T1

First value to be concatenated.

arg2 T2

Second value to be concatenated.

Returns

string

The concatenated string.

Type Parameters

T1

Any type for arg1 that can be converted to string.

T2

Any type for arg2 that can be converted to string.

Concat<T1, T2, T3>(T1, T2, T3)

Concatenates the string representation of three objects together.

public static string Concat<T1, T2, T3>(T1 arg1, T2 arg2, T3 arg3)

Parameters

arg1 T1

First value to be concatenated.

arg2 T2

Second value to be concatenated.

arg3 T3

Third value to be concatenated.

Returns

string

The concatenated string.

Type Parameters

T1

Any type for arg1 that can be converted to string.

T2

Any type for arg2 that can be converted to string.

T3

Any type for arg3 that can be converted to string.

Concat<T1, T2, T3, T4>(T1, T2, T3, T4)

Concatenates the string representation of four objects together.

public static string Concat<T1, T2, T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4)

Parameters

arg1 T1

First value to be concatenated.

arg2 T2

Second value to be concatenated.

arg3 T3

Third value to be concatenated.

arg4 T4

Fourth value to be concatenated.

Returns

string

The concatenated string.

Type Parameters

T1

Any type for arg1 that can be converted to string.

T2

Any type for arg2 that can be converted to string.

T3

Any type for arg3 that can be converted to string.

T4

Any type for arg4 that can be converted to string.

Concat<T1, T2, T3, T4, T5>(T1, T2, T3, T4, T5)

Concatenates the string representation of five objects together.

public static string Concat<T1, T2, T3, T4, T5>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)

Parameters

arg1 T1

First value to be concatenated.

arg2 T2

Second value to be concatenated.

arg3 T3

Third value to be concatenated.

arg4 T4

Fourth value to be concatenated.

arg5 T5

Fifth value to be concatenated.

Returns

string

The concatenated string.

Type Parameters

T1

Any type for arg1 that can be converted to string.

T2

Any type for arg2 that can be converted to string.

T3

Any type for arg3 that can be converted to string.

T4

Any type for arg4 that can be converted to string.

T5

Any type for arg5 that can be converted to string.

Contains(scoped ReadOnlySpan<char>, StringComparison)

Returns whether a specified substring occurs within this string.

public readonly bool Contains(scoped ReadOnlySpan<char> word, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

word ReadOnlySpan<char>

Word to look for in this string.

comparisonType StringComparison

One of the enumeration values that specifies the rules for the search.

Returns

bool

True if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.

Remarks

This method performs an ordinal (case-sensitive and culture-insensitive) comparison.

Dispose()

Disposes the instance and returns the rented buffer to the array pool if needed.

public void Dispose()

EnsureCapacity(int)

Ensures the builder's buffer size is at least newCapacity, renting a larger buffer if not.

public void EnsureCapacity(int newCapacity)

Parameters

newCapacity int

New capacity for the builder.

Remarks

If Length is already >= newCapacity, nothing is done.

Equals(scoped ReadOnlySpan<char>)

Returns whether the characters in this builder are equal to the characters in the given span.

public readonly bool Equals(scoped ReadOnlySpan<char> span)

Parameters

span ReadOnlySpan<char>

The character span to compare with the current instance.

Returns

bool

true if the characters are equal to this instance, otherwise false.

Equals(scoped ReadOnlySpan<char>, StringComparison)

Returns whether the characters in this builder are equal to the characters in the given span according to the given comparison type.

public readonly bool Equals(scoped ReadOnlySpan<char> span, StringComparison comparisonType)

Parameters

span ReadOnlySpan<char>

The character span to compare with the current instance.

comparisonType StringComparison

The way to compare the sequences of characters.

Returns

bool

true if the characters are equal to this instance, otherwise false.

GetEnumerator()

Creates an enumerator over the characters in the builder.

public readonly ValueStringBuilder.Enumerator GetEnumerator()

Returns

ValueStringBuilder.Enumerator

An enumerator over the characters in the builder.

GetPinnableReference()

Gets a pinnable reference to the represented string from this builder. The content after Length is not guaranteed to be null terminated.

public readonly ref char GetPinnableReference()

Returns

char

The pointer to the first instance of the string represented by this builder.

Remarks

This method is used for use-cases where the user wants to use "fixed" calls like the following:

using var stringBuilder = new ValueStringBuilder();
stringBuilder.Append("Hello World");
fixed (var* buffer = stringBuilder) { ... }

IndexOf(scoped ReadOnlySpan<char>, int, StringComparison)

Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.

public readonly int IndexOf(scoped ReadOnlySpan<char> word, int startIndex, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

word ReadOnlySpan<char>

Word to look for in this string.

startIndex int

Index to begin with.

comparisonType StringComparison

One of the enumeration values that specifies the rules for the search.

Returns

int

The index of the found word in this string or -1 if not found.

IndexOf(scoped ReadOnlySpan<char>, StringComparison)

Returns the index within this string of the first occurrence of the specified substring.

public readonly int IndexOf(scoped ReadOnlySpan<char> word, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

word ReadOnlySpan<char>

Word to look for in this string.

comparisonType StringComparison

One of the enumeration values that specifies the rules for the search.

Returns

int

The index of the found word in this string or -1 if not found.

Insert(int, bool)

Insert the string representation of the boolean to the builder at the given index.

public void Insert(int index, bool value)

Parameters

index int

Index where value should be inserted.

value bool

Boolean to insert into this builder.

Insert(int, char)

Insert the string representation of the character to the builder at the given index.

public void Insert(int index, char value)

Parameters

index int

Index where value should be inserted.

value char

Character to insert into this builder.

Insert(int, scoped ReadOnlySpan<char>)

Insert the given span into the builder at the given index.

public void Insert(int index, scoped ReadOnlySpan<char> value)

Parameters

index int

Index where value should be inserted.

value ReadOnlySpan<char>

String to insert into this builder.

Insert(int, Rune)

Insert the string representation of the rune to the builder at the given index.

public void Insert(int index, Rune value)

Parameters

index int

Index where value should be inserted.

value Rune

Rune to insert into this builder.

Insert<T>(int, T, scoped ReadOnlySpan<char>, int, IFormatProvider?)

Insert the string representation of the value to the builder at the given index.

public void Insert<T>(int index, T value, scoped ReadOnlySpan<char> format = default, int bufferSize = 36, IFormatProvider? formatProvider = null) where T : ISpanFormattable

Parameters

index int

Index where value should be inserted.

value T

Formattable value to insert into this builder.

format ReadOnlySpan<char>

Optional formatter. If not provided the default of the given instance is taken.

bufferSize int

Size of the buffer allocated on the stack.

formatProvider IFormatProvider

Optional format provider.

Type Parameters

T

Any ISpanFormattable.

LastIndexOf(scoped ReadOnlySpan<char>, int, StringComparison)

Returns the index within this string of the last occurrence of the specified substring, starting at the specified index.

public readonly int LastIndexOf(scoped ReadOnlySpan<char> word, int startIndex, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

word ReadOnlySpan<char>

Word to look for in this string.

startIndex int

Index to begin with.

comparisonType StringComparison

One of the enumeration values that specifies the rules for the search.

Returns

int

The index of the found word in this string or -1 if not found.

LastIndexOf(scoped ReadOnlySpan<char>, StringComparison)

Returns the index within this string of the last occurrence of the specified substring.

public readonly int LastIndexOf(scoped ReadOnlySpan<char> word, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

word ReadOnlySpan<char>

Word to look for in this string.

comparisonType StringComparison

One of the enumeration values that specifies the rules for the search.

Returns

int

The index of the found word in this string or -1 if not found.

PadLeft(int, char)

Pads the left side of the string with the given character.

public void PadLeft(int totalWidth, char paddingChar)

Parameters

totalWidth int

Total width of the string after padding.

paddingChar char

Character to pad the string with.

PadRight(int, char)

Pads the right side of the string with the given character.

public void PadRight(int totalWidth, char paddingChar)

Parameters

totalWidth int

Total width of the string after padding.

paddingChar char

Character to pad the string with.

Remove(int, int)

Removes a range of characters from this builder.

public void Remove(int startIndex, int length)

Parameters

startIndex int

The inclusive index from where the string gets removed.

length int

The length of the slice to remove.

Remarks

This method will not affect the internal size of the string.

Replace(char, char)

Replaces all instances of one character with another in this builder.

public readonly void Replace(char oldValue, char newValue)

Parameters

oldValue char

The character to replace.

newValue char

The character to replace oldValue with.

Replace(char, char, int, int)

Replaces all instances of one character with another in this builder.

public readonly void Replace(char oldValue, char newValue, int startIndex, int count)

Parameters

oldValue char

The character to replace.

newValue char

The character to replace oldValue with.

startIndex int

The index to start in this builder.

count int

The number of characters to read in this builder.

Replace(scoped ReadOnlySpan<char>, scoped ReadOnlySpan<char>)

Replaces all instances of one string with another in this builder.

public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char> newValue)

Parameters

oldValue ReadOnlySpan<char>

The string to replace.

newValue ReadOnlySpan<char>

The string to replace oldValue with.

Remarks

If newValue is empty, instances of oldValue are removed.

Replace(scoped ReadOnlySpan<char>, scoped ReadOnlySpan<char>, int, int)

Replaces all instances of one string with another in this builder.

public void Replace(scoped ReadOnlySpan<char> oldValue, scoped ReadOnlySpan<char> newValue, int startIndex, int count)

Parameters

oldValue ReadOnlySpan<char>

The string to replace.

newValue ReadOnlySpan<char>

The string to replace oldValue with.

startIndex int

The index to start in this builder.

count int

The number of characters to read in this builder.

Remarks

If newValue is empty, instances of oldValue are removed.

Replace(Rune, Rune)

Replaces all instances of one rune with another in this builder.

public void Replace(Rune oldValue, Rune newValue)

Parameters

oldValue Rune

The rune to replace.

newValue Rune

The rune to replace oldValue with.

Replace(Rune, Rune, int, int)

Replaces all instances of one rune with another in this builder.

public void Replace(Rune oldValue, Rune newValue, int startIndex, int count)

Parameters

oldValue Rune

The rune to replace.

newValue Rune

The rune to replace oldValue with.

startIndex int

The index to start in this builder.

count int

The number of characters to read in this builder.

ReplaceGeneric<T>(scoped ReadOnlySpan<char>, T)

Replaces all instances of one string with another in this builder.

public void ReplaceGeneric<T>(scoped ReadOnlySpan<char> oldValue, T newValue)

Parameters

oldValue ReadOnlySpan<char>

The string to replace.

newValue T

Object to replace oldValue with.

Type Parameters

T

Any type.

Remarks

If newValue is from type ISpanFormattable an optimized version is taken. Otherwise the ToString method is called.

ReplaceGeneric<T>(scoped ReadOnlySpan<char>, T, int, int)

Replaces all instances of one string with another in this builder.

public void ReplaceGeneric<T>(scoped ReadOnlySpan<char> oldValue, T newValue, int startIndex, int count)

Parameters

oldValue ReadOnlySpan<char>

The string to replace.

newValue T

Object to replace oldValue with.

startIndex int

The index to start in this builder.

count int

The number of characters to read in this builder.

Type Parameters

T

Any type.

Remarks

If newValue is ISpanFormattable, TryFormat is used. Otherwise, ToString is used.

Reverse()

Reverses the sequence of elements in this instance.

public readonly void Reverse()

ToString()

Creates a string instance from the builder.

public override readonly string ToString()

Returns

string

The string instance.

ToString(int)

Creates a string instance from the builder.

public readonly string ToString(int startIndex)

Parameters

startIndex int

The starting position of the substring in this instance.

Returns

string

The string instance.

ToString(int, int)

Creates a string instance from the builder.

public readonly 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

The string instance.

ToString(Range)

Creates a string instance from the builder in the given range.

public readonly string ToString(Range range)

Parameters

range Range

The range to be retrieved.

Returns

string

The string instance.

Trim()

Removes all whitespace characters from the start and end of this builder.

public void Trim()

Trim(char)

Removes all occurrences of the specified character from the start and end of this builder.

public void Trim(char value)

Parameters

value char

The character to remove.

TrimEnd()

Removes all whitespace characters from the end of this builder.

public void TrimEnd()

TrimEnd(char)

Removes all occurrences of the specified character from the end of this builder.

public void TrimEnd(char value)

Parameters

value char

The character to remove.

TrimPrefix(scoped ReadOnlySpan<char>, StringComparison)

Removes the specified sequence of characters from the start of this builder.

public void TrimPrefix(scoped ReadOnlySpan<char> value, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

value ReadOnlySpan<char>

The sequence of characters to remove.

comparisonType StringComparison

The way to compare the sequences of characters.

TrimStart()

Removes all whitespace characters from the start of this builder.

public void TrimStart()

TrimStart(char)

Removes all occurrences of the specified character from the start of this builder.

public void TrimStart(char value)

Parameters

value char

The character to remove.

TrimSuffix(scoped ReadOnlySpan<char>, StringComparison)

Removes the specified sequence of characters from the end of this builder.

public void TrimSuffix(scoped ReadOnlySpan<char> value, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

value ReadOnlySpan<char>

The sequence of characters to remove.

comparisonType StringComparison

The way to compare the sequences of characters.

TryCopyTo(Span<char>)

Tries to copy the represented string into the given Span<T>.

public readonly bool TryCopyTo(Span<char> destination)

Parameters

destination Span<char>

The destination where the internal string is copied into.

Returns

bool

True, if the copy was successful, otherwise false.

Operators

implicit operator ValueStringBuilder(scoped ReadOnlySpan<char>)

Defines the implicit conversion of a ReadOnlySpan<T> to ValueStringBuilder.

public static implicit operator ValueStringBuilder(scoped ReadOnlySpan<char> fromString)

Parameters

fromString ReadOnlySpan<char>

The string as initial buffer.

Returns

ValueStringBuilder

implicit operator ValueStringBuilder(string)

Defines the implicit conversion of a string to ValueStringBuilder.

public static implicit operator ValueStringBuilder(string fromString)

Parameters

fromString string

The string as initial buffer.

Returns

ValueStringBuilder