<PackageReference Include="Microsoft.Extensions.Primitives" Version="10.0.0-preview.4.25258.110" />

StringSegment

public struct StringSegment : IEquatable<StringSegment>, IEquatable<string>
An optimized representation of a substring.
public static readonly StringSegment Empty

A StringSegment for Empty.

public string Buffer { get; }

Gets the String buffer for this StringSegment.

public bool HasValue { get; }

Gets whether this StringSegment contains a valid value.

public char this[int index] { get; }

Gets the Char at a specified position in the current StringSegment.

public int Length { get; }

Gets the length of this StringSegment.

public int Offset { get; }

Gets the offset within the buffer for this StringSegment.

public string Value { get; }

Gets the value of this segment as a String.

public StringSegment(string buffer)

Initializes an instance of the StringSegment struct.

public StringSegment(string buffer, int offset, int length)

Initializes an instance of the StringSegment struct.

public static int Compare(StringSegment a, StringSegment b, StringComparison comparisonType)

Compares substrings of two specified StringSegment objects using the specified rules, and returns an integer that indicates their relative position in the sort order.

public static bool Equals(StringSegment a, StringSegment b, StringComparison comparisonType)

Determines whether two specified StringSegment objects have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.

public static bool IsNullOrEmpty(StringSegment value)

Indicates whether the specified StringSegment is null or an Empty string.

public static bool op_Equality(StringSegment left, StringSegment right)

Checks if two specified StringSegment have the same value.

public static StringSegment op_Implicit(string value)

Creates a new StringSegment from the given String.

public static ReadOnlySpan<char> op_Implicit(StringSegment segment)

Creates a see ReadOnlySpan<T> from the given StringSegment.

public static ReadOnlyMemory<char> op_Implicit(StringSegment segment)

Creates a see ReadOnlyMemory<T> from the given StringSegment.

public static bool op_Inequality(StringSegment left, StringSegment right)

Checks if two specified StringSegment have different values.

public ReadOnlyMemory<char> AsMemory()

Gets a ReadOnlyMemory<T> from the current StringSegment.

public ReadOnlySpan<char> AsSpan()

Gets a ReadOnlySpan<T> from the current StringSegment.

public ReadOnlySpan<char> AsSpan(int start)

Gets a ReadOnlySpan<T> from the current StringSegment that starts at the position specified by start, and has the remaining length.

public ReadOnlySpan<char> AsSpan(int start, int length)

Gets a ReadOnlySpan<T> from the current StringSegment that starts at the position specified by start, and has the specified length.

public bool EndsWith(string text, StringComparison comparisonType)

Checks if the end of this StringSegment matches the specified String when compared using the specified comparisonType.

public bool Equals(StringSegment other)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(StringSegment other, StringComparison comparisonType)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(string text)

Checks if the specified String is equal to the current StringSegment.

public bool Equals(string text, StringComparison comparisonType)

Checks if the specified String is equal to the current StringSegment.

public int IndexOf(char c, int start, int count)

Gets the zero-based index of the first occurrence of the character c in this StringSegment. The search starts at start and examines a specified number of count character positions.

public int IndexOf(char c, int start)

Gets the zero-based index of the first occurrence of the character c in this StringSegment. The search starts at start.

public int IndexOf(char c)

Gets the zero-based index of the first occurrence of the character c in this StringSegment.

public int IndexOfAny(char[] anyOf, int startIndex, int count)

Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters. The search starts at a specified character position and examines a specified number of character positions.

public int IndexOfAny(char[] anyOf, int startIndex)

Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters. The search starts at a specified character position.

public int IndexOfAny(char[] anyOf)

Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.

public int LastIndexOf(char value)

Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance.

public StringTokenizer Split(char[] chars)

Splits a string into StringSegments that are based on the characters in an array.

public bool StartsWith(string text, StringComparison comparisonType)

Checks if the beginning of this StringSegment matches the specified String when compared using the specified comparisonType.

public StringSegment Subsegment(int offset)

Retrieves a StringSegment that represents a substring from this StringSegment. The StringSegment starts at the position specified by offset.

public StringSegment Subsegment(int offset, int length)

Retrieves a StringSegment that represents a substring from this StringSegment. The StringSegment starts at the position specified by offset and has the specified length.

public string Substring(int offset)

Retrieves a substring from this StringSegment. The substring starts at the position specified by offset and has the remaining length.

public string Substring(int offset, int length)

Retrieves a substring from this StringSegment. The substring starts at the position specified by offset and has the specified length.

Removes all leading and trailing whitespaces.

Removes all trailing whitespaces.

Removes all leading whitespaces.