Open sandboxFocus

Struct CharSpan

Represents a span of char by encapsulating a substring or a range of a char array.

Namespace: PostSharp.Patterns.Formatters
Assembly: PostSharp.Patterns.Common.dll
Syntax
public readonly struct CharSpan

Constructors

Name Description
CharSpan(char[], int, int)

Initializes a new CharSpan from an array of char.

CharSpan(string)

Initializes a new CharSpan from a string, and takes the whole string.

CharSpan(string, int, int)

Initializes a new CharSpan from a string and specifies the start and lenght of the substring.

Properties

Name Description
IsBackedByCharArray

Determines whether the current CharSpan is backed by a char[]. In this case, the ToCharArraySegment() method does not allocate memory.

IsNull

Determines whether the current instance represents a null string.

Length

Gets the number of char in the span.

Methods

Name Description
FromArraySegment(ArraySegment<char>)

Converts a string into a CharSpan.

FromString(string)

Converts a string into a CharSpan.

ToCharArraySegment()

Converts the current CharSpan into an ArraySegment<T> of char. When the IsBackedByCharArray or IsNull property is true, this method does not allocate memory.

ToString()

Operators

Name Description
implicit operator CharSpan(ArraySegment<char>)

Converts an ArraySegment<T> into a CharSpan.

implicit operator CharSpan(string)

Converts a string into a CharSpan.