PostSharpAPI ReferencePost­Sharp.​Patterns.​FormattersChar­Span
Open sandboxFocus

CharSpan Class

Represents a span of System.Char by encapsulating a substring or a range of a System.Char array.

Inheritance
CharSpan
Namespace: PostSharp.Patterns.Formatters
Assembly: PostSharp.Patterns.Common.dll
Syntax
public sealed class CharSpan : ValueType

Constructors

Name Description
CharSpan(Char[], Int32, Int32)

Initializes a new CharSpan from an array of System.Char.

CharSpan(String)

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

CharSpan(String, Int32, Int32)

Initializes a new CharSpan from a System.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 System.Char in the span.

Methods

Name Description
FromArraySegment(ArraySegment<Char>)

Converts a System.String into a CharSpan.

FromString(String)

Converts a System.String into a CharSpan.

ToCharArraySegment()

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

ToString()

Operators

Name Description
Implicit(ArraySegment<Char> to CharSpan)

Converts an ArraySegment<T> into a CharSpan.

Implicit(String to CharSpan)

Converts a System.String into a CharSpan.