PostSharpAPI ReferencePost­Sharp.​Patterns.​FormattersUnsafe­String­Builder
Open sandboxFocus

UnsafeStringBuilder Class

A class similar to System.Text.StringBuilder, but implemented using unsafe C#.

Inheritance
UnsafeStringBuilder
Implements
IDisposable
Namespace: PostSharp.Patterns.Formatters
Assembly: PostSharp.Patterns.Common.dll
Syntax
public sealed class UnsafeStringBuilder : Object

Constructors

Name Description
UnsafeStringBuilder(Char*, Int32, Boolean)

Initializes a new UnsafeStringBuilder with a pre-allocated buffer/

UnsafeStringBuilder(Int32, Boolean)

Initializes a new UnsafeStringBuilder and allocates a new buffer.

Properties

Name Description
Buffer

Gets a pointer to the unmanaged buffer of the current UnsafeStringBuilder.

Capacity

Gets the capacity (number of char) of the current UnsafeStringBuilder.

IsDisposed

Determines whether the current UnsafeStringBuilder has been disposed.

Item[Int32]

Gets the char at a given position in the current UnsafeStringBuilder.

Length

Gets the current number of characters in the current UnsafeStringBuilder.

ThrowOnOverflow

true if an OverflowException should be thrown when the buffer capacity is insufficient, false if the Append method should return false without exception.

Version

Gets the version of the current UnsafeStringBuilder. This property is incremented every time the current object is reused, more specifically, when the Clear() method is called.

Methods

Name Description
Append(in CharSpan)

Appends a CharSpan to the current UnsafeStringBuilder.

Append(UnsafeString)

Appends an UnsafeString to the current UnsafeStringBuilder.

Append(UnsafeStringBuilder)

Appends the current value of a UnsafeStringBuilder to the current UnsafeStringBuilder.

Append(Boolean)

Appends a Boolean (true or false, litterally) to the current UnsafeStringBuilder.

Append(Byte)

Appends a System.Byte (with decimal formatting) to the current UnsafeStringBuilder.

Append(Char)

Appends one char to the current UnsafeStringBuilder.

Append(Char*, Int32)

Appends an unmanaged array of char to the current UnsafeStringBuilder.

Append(Char, Char)

Appends two char to the current UnsafeStringBuilder.

Append(Char, Char, Char)

Appends three char to the current UnsafeStringBuilder.

Append(Char, Char, Char, Char)

Appends four char to the current UnsafeStringBuilder.

Append(Char, Char, Char, Char, Char)

Appends five char to the current UnsafeStringBuilder.

Append(Char, Int32)

Appends several times the same char to the current UnsafeStringBuilder.

Append(Char[])

Appends an array of char to the current UnsafeStringBuilder.

Append(Char[], Int32, Int32)

Appends an array segment of char to the current UnsafeStringBuilder.

Append(Int16)

Appends a System.Int16 (with decimal formatting) to the current UnsafeStringBuilder.

Append(Int32)

Appends a Int32 (with decimal formatting) to the current UnsafeStringBuilder.

Append(Int64)

Appends a Int64 (with decimal formatting) to the current UnsafeStringBuilder.

Append(SByte)

Appends an SByte (with decimal formatting) to the current UnsafeStringBuilder.

Append(String)

Appends a System.String to the current UnsafeStringBuilder.

Append(String, Int32, Int32)

Appends a part of a System.String to the current UnsafeStringBuilder.

Append(UInt16)

Appends a UInt16 (with decimal formatting) to the current UnsafeStringBuilder.

Append(UInt32)

Appends a System.UInt32 (with decimal formatting) to the current UnsafeStringBuilder.

Append(UInt64)

Appends a System.UInt64 (with decimal formatting) to the current UnsafeStringBuilder.

Clear()

Clears the current UnsafeStringBuilder so it can be reused to build a new string.

Dispose()
Finalize()
SetNullTermination()

Appends a null character at the end of the current string, without affecting the string length. In case of overflow, if ThrowOnOverflow is false, the last character of the string is removed and the string length is decreased by 1.

Substring(Int32)

Returns the substring starting at a given index and ending at the end of the current string.

Substring(Int32, Int32)

Returns the substring starting at a given index and having a specified length.

ToString()
ToUnsafeString()

Gets an UnsafeString that provides read-only access to the current UnsafeStringBuilder.

Truncate(Int32)

Truncates the string to a maximum length.