Dijeli putem


StringSegment Struct

Definition

An optimized representation of a substring.

public value class StringSegment : IEquatable<Microsoft::Extensions::Primitives::StringSegment>, IEquatable<System::String ^>
public readonly struct StringSegment : IEquatable<Microsoft.Extensions.Primitives.StringSegment>, IEquatable<string>
type StringSegment = struct
Public Structure StringSegment
Implements IEquatable(Of String), IEquatable(Of StringSegment)
Inheritance
StringSegment
Implements

Constructors

StringSegment(String, Int32, Int32)

Initializes an instance of the StringSegment struct.

StringSegment(String)

Initializes an instance of the StringSegment struct.

Fields

Empty

A StringSegment for Empty.

Properties

Buffer

Gets the String buffer for this StringSegment.

HasValue

Gets whether this StringSegment contains a valid value.

Item[Int32]

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

Length

Gets the length of this StringSegment.

Offset

Gets the offset within the buffer for this StringSegment.

Value

Gets the value of this segment as a String.

Methods

AsMemory()

Gets a ReadOnlyMemory<T> from the current StringSegment.

AsSpan()

Gets a ReadOnlySpan<T> from the current StringSegment.

AsSpan(Int32, Int32)

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

AsSpan(Int32)

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

Compare(StringSegment, StringSegment, StringComparison)

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

EndsWith(String, StringComparison)

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

Equals(Object)

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

Equals(String, StringComparison)

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

Equals(String)

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

Equals(StringSegment, StringComparison)

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

Equals(StringSegment, StringSegment, StringComparison)

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

Equals(StringSegment)

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

GetHashCode()

Returns a hash code for this instance.

IndexOf(Char, Int32, Int32)

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.

IndexOf(Char, Int32)

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

IndexOf(Char)

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

IndexOfAny(Char[], Int32, Int32)

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.

IndexOfAny(Char[], Int32)

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.

IndexOfAny(Char[])

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

IsNullOrEmpty(StringSegment)

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

LastIndexOf(Char)

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

Split(Char[])

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

StartsWith(String, StringComparison)

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

Subsegment(Int32, Int32)

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

Subsegment(Int32)

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

Substring(Int32, Int32)

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

Substring(Int32)

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

ToString()

Returns the String represented by this StringSegment or Empty if the StringSegment does not contain a value.

Trim()

Removes all leading and trailing whitespaces.

TrimEnd()

Removes all trailing whitespaces.

TrimStart()

Removes all leading whitespaces.

Operators

Equality(StringSegment, StringSegment)

Checks if two specified StringSegment have the same value.

Implicit(String to StringSegment)

Creates a new StringSegment from the given String.

Implicit(StringSegment to ReadOnlyMemory<Char>)

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

Implicit(StringSegment to ReadOnlySpan<Char>)

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

Inequality(StringSegment, StringSegment)

Checks if two specified StringSegment have different values.

Applies to