ValueStringBuilder
Search Results for

    Show / Hide Table of Contents

    Struct ValueStringBuilder

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

    Implements
    IDisposable
    Inherited Members
    System.ValueType.Equals(System.Object)
    System.ValueType.GetHashCode()
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: LinkDotNet.StringBuilder
    Assembly: LinkDotNet.StringBuilder.dll
    Syntax
    public ref struct ValueStringBuilder
    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

    | Improve this Doc View Source

    ValueStringBuilder()

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

    Declaration
    public ValueStringBuilder()
    | Improve this Doc View Source

    ValueStringBuilder(ReadOnlySpan<Char>)

    Initializes a new instance of the ValueStringBuilder struct.

    Declaration
    public ValueStringBuilder(ReadOnlySpan<char> initialText)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> initialText

    The initial text used to initialize this instance.

    | Improve this Doc View Source

    ValueStringBuilder(Span<Char>)

    Initializes a new instance of the ValueStringBuilder struct.

    Declaration
    public ValueStringBuilder(Span<char> initialBuffer)
    Parameters
    Type Name Description
    Span<System.Char> initialBuffer

    Initial buffer for the string builder to begin with.

    | Improve this Doc View Source

    ValueStringBuilder(Int32)

    Initializes a new instance of the ValueStringBuilder struct.

    Declaration
    public ValueStringBuilder(int initialCapacity)
    Parameters
    Type Name Description
    System.Int32 initialCapacity

    The initial capacity that will be allocated for this instance.

    Properties

    | Improve this Doc View Source

    Capacity

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

    Declaration
    public readonly int Capacity { get; }
    Property Value
    Type Description
    System.Int32

    The current maximum capacity before the span must be resized.

    | Improve this Doc View Source

    Item[Int32]

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

    Declaration
    public readonly ref char this[int index] { get; }
    Parameters
    Type Name Description
    System.Int32 index

    Character position to be retrieved.

    Property Value
    Type Description
    System.Char
    | Improve this Doc View Source

    Length

    Gets the current length of the represented string.

    Declaration
    public readonly int Length { get; }
    Property Value
    Type Description
    System.Int32

    The current length of the represented string.

    Methods

    | Improve this Doc View Source

    Append(ReadOnlyMemory<Char>)

    Appends a slice of memory.

    Declaration
    public void Append(ReadOnlyMemory<char> memory)
    Parameters
    Type Name Description
    ReadOnlyMemory<System.Char> memory

    The memory to add.

    | Improve this Doc View Source

    Append(scoped, Char, str)

    Appends a string.

    Declaration
    public void Append(scoped ReadOnlySpan, char, str)
    Parameters
    Type Name Description
    scoped ReadOnlySpan
    System.Char
    str
    | Improve this Doc View Source

    Append(Boolean)

    Appends the string representation of the boolean.

    Declaration
    public void Append(bool value)
    Parameters
    Type Name Description
    System.Boolean value

    Bool value to add.

    | Improve this Doc View Source

    Append(Char)

    Appends a single character.

    Declaration
    public void Append(char value)
    Parameters
    Type Name Description
    System.Char value

    Character to add.

    | Improve this Doc View Source

    Append(Char*, Int32)

    Appends a character buffer.

    Declaration
    public void Append(char *value, int length)
    Parameters
    Type Name Description
    System.Char* value

    The pointer to the start of the buffer.

    System.Int32 length

    The number of characters in the buffer.

    | Improve this Doc View Source

    Append(Rune)

    Appends a single rune to the string builder.

    Declaration
    public void Append(Rune value)
    Parameters
    Type Name Description
    System.Text.Rune value

    Rune to add.

    | Improve this Doc View Source

    Append<T>(T, ReadOnlySpan<Char>, Int32)

    Appends the string representation of the value.

    Declaration
    public void Append<T>(T value, ReadOnlySpan<char> format = null, int bufferSize = 36)
        where T : ISpanFormattable
    Parameters
    Type Name Description
    T value

    Formattable span to add.

    ReadOnlySpan<System.Char> format

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

    System.Int32 bufferSize

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

    Type Parameters
    Name Description
    T

    Any .

    | Improve this Doc View Source

    AppendFormat<T>(ReadOnlySpan<Char>, T)

    Appends the format string to the given ValueStringBuilder instance.

    Declaration
    public void AppendFormat<T>(ReadOnlySpan<char> format, T arg)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> format

    Format string.

    T arg

    Argument for {0}.

    Type Parameters
    Name Description
    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.

    | Improve this Doc View Source

    AppendFormat<T1, T2>(ReadOnlySpan<Char>, T1, T2)

    Appends the format string to the given ValueStringBuilder instance.

    Declaration
    public void AppendFormat<T1, T2>(ReadOnlySpan<char> format, T1 arg1, T2 arg2)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> format

    Format string.

    T1 arg1

    Argument for {0}.

    T2 arg2

    Argument for {1}.

    Type Parameters
    Name Description
    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.

    | Improve this Doc View Source

    AppendFormat<T1, T2, T3>(ReadOnlySpan<Char>, T1, T2, T3)

    Appends the format string to the given ValueStringBuilder instance.

    Declaration
    public void AppendFormat<T1, T2, T3>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> format

    Format string.

    T1 arg1

    Argument for {0}.

    T2 arg2

    Argument for {1}.

    T3 arg3

    Argument for {2}.

    Type Parameters
    Name Description
    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.

    | Improve this Doc View Source

    AppendFormat<T1, T2, T3, T4>(ReadOnlySpan<Char>, T1, T2, T3, T4)

    Appends the format string to the given ValueStringBuilder instance.

    Declaration
    public void AppendFormat<T1, T2, T3, T4>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> format

    Format string.

    T1 arg1

    Argument for {0}.

    T2 arg2

    Argument for {1}.

    T3 arg3

    Argument for {2}.

    T4 arg4

    Argument for {3}.

    Type Parameters
    Name Description
    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.

    | Improve this Doc View Source

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

    Appends the format string to the given ValueStringBuilder instance.

    Declaration
    public void AppendFormat<T1, T2, T3, T4, T5>(ReadOnlySpan<char> format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> format

    Format string.

    T1 arg1

    Argument for {0}.

    T2 arg2

    Argument for {1}.

    T3 arg3

    Argument for {2}.

    T4 arg4

    Argument for {3}.

    T5 arg5

    Argument for {4}.

    Type Parameters
    Name Description
    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.

    | Improve this Doc View Source

    AppendJoin(ReadOnlySpan<Char>, IEnumerable<String>)

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

    Declaration
    public void AppendJoin(ReadOnlySpan<char> separator, IEnumerable<string> values)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> separator

    String used as separator between the entries.

    IEnumerable<System.String> values

    Enumerable of strings to be concatenated.

    | Improve this Doc View Source

    AppendJoin(Char, IEnumerable<String>)

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

    Declaration
    public void AppendJoin(char separator, IEnumerable<string> values)
    Parameters
    Type Name Description
    System.Char separator

    Character used as separator between the entries.

    IEnumerable<System.String> values

    Enumerable of strings to be concatenated.

    | Improve this Doc View Source

    AppendJoin(Rune, IEnumerable<String>)

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

    Declaration
    public void AppendJoin(Rune separator, IEnumerable<string> values)
    Parameters
    Type Name Description
    System.Text.Rune separator

    Rune used as separator between the entries.

    IEnumerable<System.String> values

    Enumerable of strings to be concatenated.

    | Improve this Doc View Source

    AppendJoin<T>(ReadOnlySpan<Char>, IEnumerable<T>)

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

    Declaration
    public void AppendJoin<T>(ReadOnlySpan<char> separator, IEnumerable<T> values)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> separator

    String used as separator between the entries.

    IEnumerable<T> values

    Enumerable to be concatenated.

    Type Parameters
    Name Description
    T

    Type of the given enumerable.

    | Improve this Doc View Source

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

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

    Declaration
    public void AppendJoin<T>(char separator, IEnumerable<T> values)
    Parameters
    Type Name Description
    System.Char separator

    Character used as separator between the entries.

    IEnumerable<T> values

    Enumerable to be concatenated.

    Type Parameters
    Name Description
    T

    Type of the given enumerable.

    | Improve this Doc View Source

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

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

    Declaration
    public void AppendJoin<T>(Rune separator, IEnumerable<T> values)
    Parameters
    Type Name Description
    System.Text.Rune separator

    Rune used as separator between the entries.

    IEnumerable<T> values

    Enumerable to be concatenated.

    Type Parameters
    Name Description
    T

    Type of the given enumerable.

    | Improve this Doc View Source

    AppendLine()

    Appends .

    Declaration
    public void AppendLine()
    | Improve this Doc View Source

    AppendLine(scoped, Char, str)

    Calls and appends .

    Declaration
    public void AppendLine(scoped ReadOnlySpan, char, str)
    Parameters
    Type Name Description
    scoped ReadOnlySpan
    System.Char
    str
    | Improve this Doc View Source

    AppendSpan(Int32)

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

    Declaration
    public Span<char> AppendSpan(int length)
    Parameters
    Type Name Description
    System.Int32 length

    Integer representing the number of characters to be appended.

    Returns
    Type Description
    Span<System.Char>

    A span with the characters appended.

    | Improve this Doc View Source

    AsSpan()

    Returns the string as an .

    Declaration
    public readonly ReadOnlySpan<char> AsSpan()
    Returns
    Type Description
    ReadOnlySpan<System.Char>

    The filled array as .

    | Improve this Doc View Source

    AsSpan(Range)

    Returns the string as an .

    Declaration
    public readonly ReadOnlySpan<char> AsSpan(Range range)
    Parameters
    Type Name Description
    Range range

    The range to be retrieved.

    Returns
    Type Description
    ReadOnlySpan<System.Char>

    The filled array as .

    | Improve this Doc View Source

    AsSpan(Int32)

    Returns the string as an .

    Declaration
    public readonly ReadOnlySpan<char> AsSpan(int startIndex)
    Parameters
    Type Name Description
    System.Int32 startIndex

    The starting position of the substring in this instance.

    Returns
    Type Description
    ReadOnlySpan<System.Char>

    The filled array as .

    | Improve this Doc View Source

    AsSpan(Int32, Int32)

    Returns the string as an .

    Declaration
    public readonly ReadOnlySpan<char> AsSpan(int startIndex, int length)
    Parameters
    Type Name Description
    System.Int32 startIndex

    The starting position of the substring in this instance.

    System.Int32 length

    The length of the substring.

    Returns
    Type Description
    ReadOnlySpan<System.Char>

    The filled array as .

    | Improve this Doc View Source

    Clear()

    Clears the internal representation of the string.

    Declaration
    public void Clear()
    Remarks

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

    | Improve this Doc View Source

    Concat<T>(T[])

    Concatenates multiple objects together.

    Declaration
    public static string Concat<T>(params T[] values)
    Parameters
    Type Name Description
    T[] values

    Values to be concatenated together.

    Returns
    Type Description
    System.String

    Concatenated string or an empty string if values is empty.

    Type Parameters
    Name Description
    T

    Any given type, which can be translated to System.String.

    | Improve this Doc View Source

    Concat<T1, T2>(T1, T2)

    Concatenates two different types together.

    Declaration
    public static string Concat<T1, T2>(T1 arg1, T2 arg2)
    Parameters
    Type Name Description
    T1 arg1

    First argument.

    T2 arg2

    Second argument.

    Returns
    Type Description
    System.String

    String representation of the concateneted result.

    Type Parameters
    Name Description
    T1

    Typeparameter of arg1.

    T2

    Typeparameter of arg2.

    | Improve this Doc View Source

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

    Concatenates two different types together.

    Declaration
    public static string Concat<T1, T2, T3>(T1 arg1, T2 arg2, T3 arg3)
    Parameters
    Type Name Description
    T1 arg1

    First argument.

    T2 arg2

    Second argument.

    T3 arg3

    Third argument.

    Returns
    Type Description
    System.String

    String representation of the concateneted result.

    Type Parameters
    Name Description
    T1

    Typeparameter of arg1.

    T2

    Typeparameter of arg2.

    T3

    Typeparameter of arg3.

    | Improve this Doc View Source

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

    Concatenates two different types together.

    Declaration
    public static string Concat<T1, T2, T3, T4>(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
    Parameters
    Type Name Description
    T1 arg1

    First argument.

    T2 arg2

    Second argument.

    T3 arg3

    Third argument.

    T4 arg4

    Fourth argument.

    Returns
    Type Description
    System.String

    String representation of the concateneted result.

    Type Parameters
    Name Description
    T1

    Typeparameter of arg1.

    T2

    Typeparameter of arg2.

    T3

    Typeparameter of arg3.

    T4

    Typeparameter of arg4.

    | Improve this Doc View Source

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

    Concatenates two different types together.

    Declaration
    public static string Concat<T1, T2, T3, T4, T5>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
    Parameters
    Type Name Description
    T1 arg1

    First argument.

    T2 arg2

    Second argument.

    T3 arg3

    Third argument.

    T4 arg4

    Fourth argument.

    T5 arg5

    Fifth argument.

    Returns
    Type Description
    System.String

    String representation of the concateneted result.

    Type Parameters
    Name Description
    T1

    Typeparameter of arg1.

    T2

    Typeparameter of arg2.

    T3

    Typeparameter of arg3.

    T4

    Typeparameter of arg4.

    T5

    Typeparameter of arg5.

    | Improve this Doc View Source

    Contains(ReadOnlySpan<Char>)

    Returns whether a specified substring occurs within this string.

    Declaration
    public readonly bool Contains(ReadOnlySpan<char> word)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> word

    Word to look for in this string.

    Returns
    Type Description
    System.Boolean

    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.

    | Improve this Doc View Source

    Dispose()

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

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    EnsureCapacity(Int32)

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

    Declaration
    public void EnsureCapacity(int newCapacity)
    Parameters
    Type Name Description
    System.Int32 newCapacity

    New capacity for the builder.

    Remarks

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

    | Improve this Doc View Source

    Equals(ReadOnlySpan<Char>)

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

    Declaration
    public readonly bool Equals(ReadOnlySpan<char> span)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> span

    The character span to compare with the current instance.

    Returns
    Type Description
    System.Boolean

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

    | Improve this Doc View Source

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

    Declaration
    public readonly bool Equals(ReadOnlySpan<char> span, StringComparison comparisonType)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> span

    The character span to compare with the current instance.

    StringComparison comparisonType

    The way to compare the sequences of characters.

    Returns
    Type Description
    System.Boolean

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

    | Improve this Doc View Source

    GetEnumerator()

    Creates an enumerator over the characters in the builder.

    Declaration
    public readonly ValueStringBuilder.Enumerator GetEnumerator()
    Returns
    Type Description
    ValueStringBuilder.Enumerator

    An enumerator over the characters in the builder.

    | Improve this Doc View Source

    GetPinnableReference()

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

    Declaration
    public readonly ref char GetPinnableReference()
    Returns
    Type Description
    System.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) { ... }
    | Improve this Doc View Source

    IndexOf(ReadOnlySpan<Char>)

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

    Declaration
    public readonly int IndexOf(ReadOnlySpan<char> word)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> word

    Word to look for in this string.

    Returns
    Type Description
    System.Int32

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

    | Improve this Doc View Source

    IndexOf(ReadOnlySpan<Char>, Int32)

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

    Declaration
    public readonly int IndexOf(ReadOnlySpan<char> word, int startIndex)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> word

    Word to look for in this string.

    System.Int32 startIndex

    Index to begin with.

    Returns
    Type Description
    System.Int32

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

    | Improve this Doc View Source

    Insert(Int32, scoped, Char, value)

    Appends the string representation of the boolean to the builder.

    Declaration
    public void Insert(int index, scoped ReadOnlySpan, char, value)
    Parameters
    Type Name Description
    System.Int32 index

    Index where value should be inserted.

    scoped ReadOnlySpan
    System.Char
    value
    | Improve this Doc View Source

    Insert(Int32, Boolean)

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

    Declaration
    public void Insert(int index, bool value)
    Parameters
    Type Name Description
    System.Int32 index

    Index where value should be inserted.

    System.Boolean value

    Boolean to insert into this builder.

    | Improve this Doc View Source

    Insert(Int32, Char)

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

    Declaration
    public void Insert(int index, char value)
    Parameters
    Type Name Description
    System.Int32 index

    Index where value should be inserted.

    System.Char value

    Character to insert into this builder.

    | Improve this Doc View Source

    Insert(Int32, Rune)

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

    Declaration
    public void Insert(int index, Rune value)
    Parameters
    Type Name Description
    System.Int32 index

    Index where value should be inserted.

    System.Text.Rune value

    Rune to insert into this builder.

    | Improve this Doc View Source

    Insert<T>(Int32, T, scoped, Char, format, Int32)

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

    Declaration
    public void Insert<T>(int index, T value, scoped ReadOnlySpan, char, format  = null, int bufferSize = 36)
        where T : ISpanFormattable
    Parameters
    Type Name Description
    System.Int32 index

    Index where value should be inserted.

    T value

    Formattable span to insert into this builder.

    scoped ReadOnlySpan
    System.Char
    format
    System.Int32 bufferSize

    Size of the buffer allocated on the stack.

    Type Parameters
    Name Description
    T

    Any .

    | Improve this Doc View Source

    LastIndexOf(ReadOnlySpan<Char>)

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

    Declaration
    public readonly int LastIndexOf(ReadOnlySpan<char> word)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> word

    Word to look for in this string.

    Returns
    Type Description
    System.Int32

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

    | Improve this Doc View Source

    LastIndexOf(ReadOnlySpan<Char>, Int32)

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

    Declaration
    public readonly int LastIndexOf(ReadOnlySpan<char> word, int startIndex)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> word

    Word to look for in this string.

    System.Int32 startIndex

    Index to begin with.

    Returns
    Type Description
    System.Int32

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

    | Improve this Doc View Source

    PadLeft(Int32, Char)

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

    Declaration
    public void PadLeft(int totalWidth, char paddingChar)
    Parameters
    Type Name Description
    System.Int32 totalWidth

    Total width of the string after padding.

    System.Char paddingChar

    Character to pad the string with.

    | Improve this Doc View Source

    PadRight(Int32, Char)

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

    Declaration
    public void PadRight(int totalWidth, char paddingChar)
    Parameters
    Type Name Description
    System.Int32 totalWidth

    Total width of the string after padding.

    System.Char paddingChar

    Character to pad the string with.

    | Improve this Doc View Source

    Remove(Int32, Int32)

    Removes a range of characters from this builder.

    Declaration
    public void Remove(int startIndex, int length)
    Parameters
    Type Name Description
    System.Int32 startIndex

    The inclusive index from where the string gets removed.

    System.Int32 length

    The length of the slice to remove.

    Remarks

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

    | Improve this Doc View Source

    Replace(scoped, Char, oldValue, scoped, Char, newValue)

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

    Declaration
    public void Replace(scoped ReadOnlySpan, char, oldValue, scoped ReadOnlySpan, char, newValue)
    Parameters
    Type Name Description
    scoped ReadOnlySpan
    System.Char
    oldValue
    scoped ReadOnlySpan
    System.Char
    newValue
    Remarks

    If newValue is empty, instances of oldValue are removed.

    | Improve this Doc View Source

    Replace(scoped, Char, oldValue, scoped, Char, newValue, Int32, Int32)

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

    Declaration
    public void Replace(scoped ReadOnlySpan, char, oldValue, scoped ReadOnlySpan, char, newValue, int startIndex, int count)
    Parameters
    Type Name Description
    scoped ReadOnlySpan
    System.Char
    oldValue
    scoped ReadOnlySpan
    System.Char
    newValue
    System.Int32 startIndex

    The index to start in this builder.

    System.Int32 count

    The number of characters to read in this builder.

    Remarks

    If newValue is empty, instances of oldValue are removed.

    | Improve this Doc View Source

    Replace(Char, Char)

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

    Declaration
    public readonly void Replace(char oldValue, char newValue)
    Parameters
    Type Name Description
    System.Char oldValue

    The character to replace.

    System.Char newValue

    The character to replace oldValue with.

    | Improve this Doc View Source

    Replace(Char, Char, Int32, Int32)

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

    Declaration
    public readonly void Replace(char oldValue, char newValue, int startIndex, int count)
    Parameters
    Type Name Description
    System.Char oldValue

    The character to replace.

    System.Char newValue

    The character to replace oldValue with.

    System.Int32 startIndex

    The index to start in this builder.

    System.Int32 count

    The number of characters to read in this builder.

    | Improve this Doc View Source

    Replace(Rune, Rune)

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

    Declaration
    public void Replace(Rune oldValue, Rune newValue)
    Parameters
    Type Name Description
    System.Text.Rune oldValue

    The rune to replace.

    System.Text.Rune newValue

    The rune to replace oldValue with.

    | Improve this Doc View Source

    Replace(Rune, Rune, Int32, Int32)

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

    Declaration
    public void Replace(Rune oldValue, Rune newValue, int startIndex, int count)
    Parameters
    Type Name Description
    System.Text.Rune oldValue

    The rune to replace.

    System.Text.Rune newValue

    The rune to replace oldValue with.

    System.Int32 startIndex

    The index to start in this builder.

    System.Int32 count

    The number of characters to read in this builder.

    | Improve this Doc View Source

    ReplaceGeneric<T>(scoped, Char, oldValue, T)

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

    Declaration
    public void ReplaceGeneric<T>(scoped ReadOnlySpan, char, oldValue, T newValue)
    Parameters
    Type Name Description
    scoped ReadOnlySpan
    System.Char
    oldValue
    T newValue

    Object to replace oldValue with.

    Type Parameters
    Name Description
    T

    Any type.

    Remarks

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

    | Improve this Doc View Source

    ReplaceGeneric<T>(scoped, Char, oldValue, T, Int32, Int32)

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

    Declaration
    public void ReplaceGeneric<T>(scoped ReadOnlySpan, char, oldValue, T newValue, int startIndex, int count)
    Parameters
    Type Name Description
    scoped ReadOnlySpan
    System.Char
    oldValue
    T newValue

    Object to replace oldValue with.

    System.Int32 startIndex

    The index to start in this builder.

    System.Int32 count

    The number of characters to read in this builder.

    Type Parameters
    Name Description
    T

    Any type.

    Remarks

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

    | Improve this Doc View Source

    Reverse()

    Reverses the sequence of elements in this instance.

    Declaration
    public readonly void Reverse()
    | Improve this Doc View Source

    ToString()

    Creates a System.String instance from the builder.

    Declaration
    public override readonly string ToString()
    Returns
    Type Description
    System.String

    The System.String instance.

    Overrides
    System.ValueType.ToString()
    | Improve this Doc View Source

    ToString(Range)

    Creates a System.String instance from the builder in the given range.

    Declaration
    public readonly string ToString(Range range)
    Parameters
    Type Name Description
    Range range

    The range to be retrieved.

    Returns
    Type Description
    System.String

    The System.String instance.

    | Improve this Doc View Source

    ToString(Int32)

    Creates a System.String instance from the builder.

    Declaration
    public readonly string ToString(int startIndex)
    Parameters
    Type Name Description
    System.Int32 startIndex

    The starting position of the substring in this instance.

    Returns
    Type Description
    System.String

    The System.String instance.

    | Improve this Doc View Source

    ToString(Int32, Int32)

    Creates a System.String instance from the builder.

    Declaration
    public readonly string ToString(int startIndex, int length)
    Parameters
    Type Name Description
    System.Int32 startIndex

    The starting position of the substring in this instance.

    System.Int32 length

    The length of the substring.

    Returns
    Type Description
    System.String

    The System.String instance.

    | Improve this Doc View Source

    Trim()

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

    Declaration
    public void Trim()
    | Improve this Doc View Source

    Trim(Char)

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

    Declaration
    public void Trim(char value)
    Parameters
    Type Name Description
    System.Char value

    The character to remove.

    | Improve this Doc View Source

    TrimEnd()

    Removes all whitespace characters from the end of this builder.

    Declaration
    public void TrimEnd()
    | Improve this Doc View Source

    TrimEnd(Char)

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

    Declaration
    public void TrimEnd(char value)
    Parameters
    Type Name Description
    System.Char value

    The character to remove.

    | Improve this Doc View Source

    TrimPrefix(ReadOnlySpan<Char>, StringComparison)

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

    Declaration
    public void TrimPrefix(ReadOnlySpan<char> value, StringComparison comparisonType = null)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> value

    The sequence of characters to remove.

    StringComparison comparisonType

    The way to compare the sequences of characters.

    | Improve this Doc View Source

    TrimStart()

    Removes all whitespace characters from the start of this builder.

    Declaration
    public void TrimStart()
    | Improve this Doc View Source

    TrimStart(Char)

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

    Declaration
    public void TrimStart(char value)
    Parameters
    Type Name Description
    System.Char value

    The character to remove.

    | Improve this Doc View Source

    TrimSuffix(ReadOnlySpan<Char>, StringComparison)

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

    Declaration
    public void TrimSuffix(ReadOnlySpan<char> value, StringComparison comparisonType = null)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> value

    The sequence of characters to remove.

    StringComparison comparisonType

    The way to compare the sequences of characters.

    | Improve this Doc View Source

    TryCopyTo(Span<Char>)

    Tries to copy the represented string into the given .

    Declaration
    public readonly bool TryCopyTo(Span<char> destination)
    Parameters
    Type Name Description
    Span<System.Char> destination

    The destination where the internal string is copied into.

    Returns
    Type Description
    System.Boolean

    True, if the copy was successful, otherwise false.

    Operators

    | Improve this Doc View Source

    Implicit(ReadOnlySpan<Char> to ValueStringBuilder)

    Defines the implicit conversion of a to ValueStringBuilder.

    Declaration
    public static implicit operator ValueStringBuilder(ReadOnlySpan<char> fromString)
    Parameters
    Type Name Description
    ReadOnlySpan<System.Char> fromString

    The string as initial buffer.

    Returns
    Type Description
    ValueStringBuilder
    | Improve this Doc View Source

    Implicit(String to ValueStringBuilder)

    Defines the implicit conversion of a System.String to ValueStringBuilder.

    Declaration
    public static implicit operator ValueStringBuilder(string fromString)
    Parameters
    Type Name Description
    System.String fromString

    The string as initial buffer.

    Returns
    Type Description
    ValueStringBuilder

    Implements

    IDisposable

    Extension Methods

    ValueStringBuilderExtensions.ToStringBuilder(ValueStringBuilder)
    • Improve this Doc
    • View Source
    In This Article