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

將此區段的值作為 String 取得。Gets the value of this segment as a String.

方法

AsMemory()

從目前的 StringSegment 取得 ReadOnlyMemory<T>Gets a ReadOnlyMemory<T> from the current StringSegment.

AsSpan()

從目前的 StringSegment 取得 ReadOnlySpan<T>Gets 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 是否與目前的 StringSegment 相等。Checks if the specified String is equal to the current StringSegment.

Equals(String, StringComparison)

檢查指定的 String 是否與目前的 StringSegment 相等。Checks 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)

取得此 StringSegment 中第一次出現 c 字元位置的以零起始索引。Gets the zero-based index of the first occurrence of the character c in this StringSegment.

IndexOf(Char, Int32)

取得此 StringSegment 中第一次出現 c 字元位置的以零起始索引。Gets the zero-based index of the first occurrence of the character c in this StringSegment. 搜尋會在 start 開始。The search starts at start.

IndexOf(Char, Int32, Int32)

取得此 StringSegment 中第一次出現 c 字元位置的以零起始索引。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,代表此 StringSegment 中的子字串。Retrieves a StringSegment that represents a substring from this StringSegment. StringSegment 會從 offset 指定的位置開始。The StringSegment starts at the position specified by offset.

Subsegment(Int32, Int32)

擷取 StringSegment,代表此 StringSegment 中的子字串。Retrieves a StringSegment that represents a substring from this StringSegment. StringSegment 會從 offset 指定的位置開始,並具有指定的 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代表的 String,或Returns the String represented by this StringSegment or

String.Empty
表示 StringSegment 不包含任何值。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.

適用於