StringSegment 结构

定义

子字符串的优化表示形式。An optimized representation of a substring.

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

构造函数

StringSegment(String)

初始化 StringSegment 结构的实例。Initializes an instance of the StringSegment struct.

StringSegment(String, Int32, Int32)

初始化 StringSegment 结构的实例。Initializes an instance of the StringSegment struct.

字段

Empty

EmptyStringSegmentA StringSegment for Empty.

属性

Buffer

获取此 StringSegmentString 缓冲区。Gets the String buffer for this StringSegment.

HasValue

获取此 StringSegment 是否包含有效的值。Gets whether this StringSegment contains a valid value.

Item[Int32]

获取位于当前 StringSegment 中指定位置的 CharGets the Char at a specified position in the current StringSegment.

Length

获取 StringSegment 的长度。Gets the length of this StringSegment.

Offset

获取此 StringSegment 的缓冲区内的偏移量。Gets the offset within the buffer for this StringSegment.

Value

获取此段的值作为 StringGets the value of this segment as a String.

方法

AsMemory()

从当前 ReadOnlyMemory<T> 中获取 StringSegmentGets a ReadOnlyMemory<T> from the current StringSegment.

AsSpan()

从当前 ReadOnlySpan<T> 中获取 StringSegmentGets a ReadOnlySpan<T> from the current StringSegment.

Compare(StringSegment, StringSegment, StringComparison)

使用指定的规则比较两个指定的 StringSegment 对象的子字符串,并返回一个整数,指示二者在排序顺序中的相对位置。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)

使用指定的 comparisonType 进行比较时,检查此 StringSegment 的结尾是否与指定的 String 匹配。Checks if the end of this StringSegment matches the specified String when compared using the specified comparisonType.

Equals(Object)
Equals(String)

检查指定的 String 是否等于当前的 StringSegmentChecks if the specified String is equal to the current StringSegment.

Equals(String, StringComparison)

检查指定的 String 是否等于当前的 StringSegmentChecks if the specified String is equal to the current StringSegment.

Equals(StringSegment)

指示当前对象是否等于同一类型的另一个对象。Indicates whether the current object is equal to another object of the same type.

Equals(StringSegment, StringComparison)

指示当前对象是否等于同一类型的另一个对象。Indicates whether the current object is equal to another object of the same type.

Equals(StringSegment, StringSegment, StringComparison)

确定两个指定的 StringSegment 对象是否具有相同的值。Determines whether two specified StringSegment objects have the same value. 参数指定区域性、大小写以及比较所用的排序规则。A parameter specifies the culture, case, and sort rules used in the comparison.

GetHashCode()
IndexOf(Char)

获取 c 字符在此 StringSegment 中的第一个匹配项从零开始的索引。Gets the zero-based index of the first occurrence of the character c in this StringSegment.

IndexOf(Char, Int32)

获取 c 字符在此 StringSegment 中的第一个匹配项从零开始的索引。Gets the zero-based index of the first occurrence of the character c in this StringSegment. 搜索的起始位置为 startThe search starts at start.

IndexOf(Char, Int32, Int32)

获取 c 字符在此 StringSegment 中的第一个匹配项从零开始的索引。Gets the zero-based index of the first occurrence of the character c in this StringSegment. 搜索从 start 开始,并检查指定数量的 count 字符位置。The search starts at start and examines a specified number of count character positions.

IndexOfAny(Char[])

报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的从零开始的索引。Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.

IndexOfAny(Char[], Int32)

报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的从零开始的索引。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[], Int32, Int32)

报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的从零开始的索引。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.

IsNullOrEmpty(StringSegment)

指示指定的 StringSegment 是 null 还是空字符串。Indicates whether the specified StringSegment is null or an Empty string.

LastIndexOf(Char)

报告指定 Unicode 字符在此实例中的最后一个匹配项的从零开始的索引的位置。Reports the zero-based index position of the last occurrence of a specified Unicode character within this instance.

Split(Char[])

基于数组中的字符将字符串拆分为 StringSegmentSplits a string into StringSegments that are based on the characters in an array.

StartsWith(String, StringComparison)

使用指定的 comparisonType 进行比较时,检查此 StringSegment 的开头是否与指定的 String 匹配。Checks if the beginning of this StringSegment matches the specified String when compared using the specified comparisonType.

Subsegment(Int32)

检索表示此 StringSegment 中的子字符串的 StringSegmentRetrieves a StringSegment that represents a substring from this StringSegment. StringSegmentoffset 指定的位置开始。The StringSegment starts at the position specified by offset.

Subsegment(Int32, Int32)

检索表示此 StringSegment 中的子字符串的 StringSegmentRetrieves a StringSegment that represents a substring from this StringSegment. StringSegmentoffset 指定的位置开始,并具有指定的 lengthThe StringSegment starts at the position specified by offset and has the specified length.

Substring(Int32)

从此 StringSegment 检索子字符串。Retrieves a substring from this StringSegment. 子字符串从 offset 指定的位置开始,并具有剩余长度。The substring starts at the position specified by offset and has the remaining length.

Substring(Int32, Int32)

从此 StringSegment 检索子字符串。Retrieves a substring from this StringSegment. 子字符串从 offset 指定的位置开始,并具有指定的 lengthThe substring starts at the position specified by offset and has the specified length.

ToString()

如果 StringSegment 不包含值,则返回由此 StringSegmentEmpty 表示的 StringReturns 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.

运算符

Equality(StringSegment, StringSegment)

检查两个指定的 StringSegment 是否具有相同的值。Checks if two specified StringSegment have the same value.

Implicit(String to StringSegment)

从给定的 String 创建新的 StringSegmentCreates a new StringSegment from the given String.

Implicit(StringSegment to ReadOnlyMemory<Char>)
Implicit(StringSegment to ReadOnlySpan<Char>)
Inequality(StringSegment, StringSegment)

检查两个指定的 StringSegment 是否具有不同的值。Checks if two specified StringSegment have different values.

适用于