Class StringSegment
Value representing a segment in a string used to reduce allocations of string copies.
Inheritance
Implements
Namespace: System
Assembly: Nuqleon.StringSegment.dll
Syntax
public sealed class StringSegment : ValueType, IEquatable<StringSegment>, IEnumerable<char>, IEnumerable, IComparable, IComparable<StringSegment>
Constructors
StringSegment(Char, Int32)
Initializes a new string segment to the value indicated by a specified Unicode character repeated a specified number of times.
Declaration
public StringSegment(char c, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char | c | A Unicode character. |
System.Int32 | count | The number of times c occurs. |
StringSegment(Char[])
Initializes a new string segment to the value indicated by an array of Unicode characters.
Declaration
public StringSegment(char[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | value | An array of Unicode characters. |
StringSegment(Char[], Int32, Int32)
Initializes a new string segment to the value indicated by an array of Unicode characters, a starting character position within that array, and a length.
Declaration
public StringSegment(char[] value, int startIndex, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | value | An array of Unicode characters. |
System.Int32 | startIndex | The starting position within value. |
System.Int32 | length | The number of characters within value to use. |
StringSegment(String)
Creates a string segment representing the specified string.
Declaration
public StringSegment(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to wrap in a string segment. |
StringSegment(String, Int32, Int32)
Creates a string segment representing the specified number of characters in the specified string starting from the specified start index.
Declaration
public StringSegment(string value, int startIndex, int length)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to wrap in a string segment. |
System.Int32 | startIndex | The index of the first character exposed by the segment. |
System.Int32 | length | The number of characters exposed by the segment, starting from the specified start index. |
Fields
Empty
Gets an empty string segment.
Declaration
public static readonly StringSegment Empty
Field Value
Type | Description |
---|---|
StringSegment |
Properties
Chars[Int32]
Gets the character at the specified index.
Declaration
public char this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the character to retrieve. |
Property Value
Type | Description |
---|---|
System.Char | The character at the specified index. |
Length
Gets the number of characters in the string segment.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
StartIndex
Gets the index of the first character in the underlying string exposed by the string segment.
Declaration
public int StartIndex { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
String
Gets the string over which the string segment was created.
Declaration
public string String { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
AsSpan()
Creates a new read-only span over the string segment.
Declaration
public ReadOnlySpan<char> AsSpan()
Returns
Type | Description |
---|---|
System.ReadOnlySpan<System.Char> | A read-only span over the string segment. |
Compare(StringSegment, Int32, StringSegment, Int32, Int32)
Compares substrings of two specified string segments and returns an integer that indicates their relative position in the sort order.
Declaration
public static int Compare(StringSegment strA, int indexA, StringSegment strB, int indexB, int length)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to use in the comparison. |
System.Int32 | indexA | The position of the substring within strA. |
StringSegment | strB | The second string to use in the comparison. |
System.Int32 | indexB | The position of the substring within strB. |
System.Int32 | length | The maximum number of characters in the substrings to compare. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, Int32, StringSegment, Int32, Int32, Boolean)
Compares substrings of two specified string segments, ignoring or honoring their case, and returns an integer that indicates their relative position in the sort order.
Declaration
public static int Compare(StringSegment strA, int indexA, StringSegment strB, int indexB, int length, bool ignoreCase)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to use in the comparison. |
System.Int32 | indexA | The position of the substring within strA. |
StringSegment | strB | The second string to use in the comparison. |
System.Int32 | indexB | The position of the substring within strB. |
System.Int32 | length | The maximum number of characters in the substrings to compare. |
System.Boolean | ignoreCase | true to ignore case during the comparison; otherwise, false. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, Int32, StringSegment, Int32, Int32, Boolean, CultureInfo)
Compares substrings of two specified string segments, ignoring or honoring their case and using culture-specific information to influence the comparison, and returns an integer that indicates their relative position in the sort order.
Declaration
public static int Compare(StringSegment strA, int indexA, StringSegment strB, int indexB, int length, bool ignoreCase, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to use in the comparison. |
System.Int32 | indexA | The position of the substring within strA. |
StringSegment | strB | The second string to use in the comparison. |
System.Int32 | indexB | The position of the substring within strB. |
System.Int32 | length | The maximum number of characters in the substrings to compare. |
System.Boolean | ignoreCase | true to ignore case during the comparison; otherwise, false. |
System.Globalization.CultureInfo | culture | An object that supplies culture-specific comparison information. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, Int32, StringSegment, Int32, Int32, CultureInfo, CompareOptions)
Compares substrings of two specified string segments using the specified comparison options and culture-specific information to influence the comparison, and returns an integer that indicates the relationship of the two substrings to each other in the sort order.
Declaration
public static int Compare(StringSegment strA, int indexA, StringSegment strB, int indexB, int length, CultureInfo culture, CompareOptions options)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to use in the comparison. |
System.Int32 | indexA | The position of the substring within strA. |
StringSegment | strB | The second string to use in the comparison. |
System.Int32 | indexB | The position of the substring within strB. |
System.Int32 | length | The maximum number of characters in the substrings to compare. |
System.Globalization.CultureInfo | culture | An object that supplies culture-specific comparison information. |
System.Globalization.CompareOptions | options | Options to use when performing the comparison (such as ignoring case or symbols). |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, Int32, StringSegment, Int32, Int32, StringComparison)
Compares substrings of two specified string segments using the specified rules, and returns an integer that indicates their relative position in the sort order.
Declaration
public static int Compare(StringSegment strA, int indexA, StringSegment strB, int indexB, int length, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to use in the comparison. |
System.Int32 | indexA | The position of the substring within strA. |
StringSegment | strB | The second string to use in the comparison. |
System.Int32 | indexB | The position of the substring within strB. |
System.Int32 | length | The maximum number of characters in the substrings to compare. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules to use in the comparison. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, StringSegment)
Compares two specified string segments and returns an integer that indicates their relative position in the sort order.
Declaration
public static int Compare(StringSegment strA, StringSegment strB)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to compare. |
StringSegment | strB | The second string to compare. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, StringSegment, Boolean)
Compares two specified string segments, ignoring or honoring their case, and returns an integer that indicates their relative position in the sort order.
Declaration
public static int Compare(StringSegment strA, StringSegment strB, bool ignoreCase)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to compare. |
StringSegment | strB | The second string to compare. |
System.Boolean | ignoreCase | true to ignore case during the comparison; otherwise, false. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, StringSegment, Boolean, CultureInfo)
Compares two specified string segments, ignoring or honoring their case, and using culture-specific information to influence the comparison, and returns an integer that indicates their relative position in the sort order.
Declaration
public static int Compare(StringSegment strA, StringSegment strB, bool ignoreCase, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to compare. |
StringSegment | strB | The second string to compare. |
System.Boolean | ignoreCase | true to ignore case during the comparison; otherwise, false. |
System.Globalization.CultureInfo | culture | An object that supplies culture-specific comparison information. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, StringSegment, CultureInfo, CompareOptions)
Compares two specified string segments using the specified comparison options and culture-specific information to influence the comparison, and returns an integer that indicates the relationship of the two strings to each other in the sort order.
Declaration
public static int Compare(StringSegment strA, StringSegment strB, CultureInfo culture, CompareOptions options)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to compare. |
StringSegment | strB | The second string to compare. |
System.Globalization.CultureInfo | culture | An object that supplies culture-specific comparison information. |
System.Globalization.CompareOptions | options | Options to use when performing the comparison (such as ignoring case or symbols). |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
Compare(StringSegment, StringSegment, StringComparison)
Compares two specified string segments using the specified rules, and returns an integer that indicates their relative position in the sort order.
Declaration
public static int Compare(StringSegment strA, StringSegment strB, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to compare. |
StringSegment | strB | The second string to compare. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules to use in the comparison. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
CompareOrdinal(StringSegment, Int32, StringSegment, Int32, Int32)
Compares substrings of two specified string segments by evaluating the numeric values of the corresponding System.Char objects in each substring.
Declaration
public static int CompareOrdinal(StringSegment strA, int indexA, StringSegment strB, int indexB, int length)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to use in the comparison. |
System.Int32 | indexA | The starting index of the substring in strA. |
StringSegment | strB | The second string to use in the comparison. |
System.Int32 | indexB | The starting index of the substring in strB. |
System.Int32 | length | The maximum number of characters in the substrings to compare. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
CompareOrdinal(StringSegment, StringSegment)
Compares two specified string segments by evaluating the numeric values of the corresponding System.Char objects in each string.
Declaration
public static int CompareOrdinal(StringSegment strA, StringSegment strB)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strA | The first string to compare. |
StringSegment | strB | The second string to compare. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the lexical relationship between the two comparands. |
CompareTo(Object)
Compares the string represented by the string segment to the specified object and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified object.
Declaration
public int CompareTo(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to compare to. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the value parameter. |
CompareTo(StringSegment)
Compares the string represented by the string segment to the string represented by the specified string segment and indicates whether this instance precedes, follows, or appears in the same position in the sort order as the specified string segment.
Declaration
public int CompareTo(StringSegment strB)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | strB | The string segment to compare to. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates whether this instance precedes, follows, or appears in the same position in the sort order as the value parameter. |
Concat(IEnumerable<StringSegment>)
Concatenates the members of a constructed IEnumerable{T} collection of type string segments.
Declaration
public static StringSegment Concat(IEnumerable<StringSegment> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<StringSegment> | values | A collection object that implements IEnumerable{T} and whose generic type argument is StringSegment. |
Returns
Type | Description |
---|---|
StringSegment | The concatenated strings in values. |
Concat(Object)
Creates the string representation of a specified object.
Declaration
public static StringSegment Concat(object arg0)
Parameters
Type | Name | Description |
---|---|---|
System.Object | arg0 | The object to represent, or null. |
Returns
Type | Description |
---|---|
StringSegment | The string representation of the value of arg0, or Empty if arg0 is null. |
Concat(Object, Object)
Concatenates the string representations of two specified objects.
Declaration
public static StringSegment Concat(object arg0, object arg1)
Parameters
Type | Name | Description |
---|---|---|
System.Object | arg0 | The first object to concatenate. |
System.Object | arg1 | The second object to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | The concatenated string representations of the values of arg0 and arg1. |
Concat(Object, Object, Object)
Concatenates the string representations of three specified objects.
Declaration
public static StringSegment Concat(object arg0, object arg1, object arg2)
Parameters
Type | Name | Description |
---|---|---|
System.Object | arg0 | The first object to concatenate. |
System.Object | arg1 | The second object to concatenate. |
System.Object | arg2 | The third object to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | The concatenated string representations of the values of arg0, arg1, and arg2. |
Concat(Object, Object, Object, Object)
Concatenates the string representations of four specified objects.
Declaration
public static StringSegment Concat(object arg0, object arg1, object arg2, object arg3)
Parameters
Type | Name | Description |
---|---|---|
System.Object | arg0 | The first object to concatenate. |
System.Object | arg1 | The second object to concatenate. |
System.Object | arg2 | The third object to concatenate. |
System.Object | arg3 | The fourth object to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | The concatenated string representations of the values of arg0, arg1, arg2, and arg3. |
Concat(Object, Object, Object, Object)
Concatenates the string representations of four specified objects and the objects in the arg iterator.
Declaration
public static StringSegment Concat(object arg0, object arg1, object arg2, object arg3)
Parameters
Type | Name | Description |
---|---|---|
System.Object | arg0 | The first object to concatenate. |
System.Object | arg1 | The second object to concatenate. |
System.Object | arg2 | The third object to concatenate. |
System.Object | arg3 | The fourth object to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | The concatenated string representations of the values of arg0, arg1, arg2, arg3, and the values in the arg iterator. |
Concat(Object[])
Concatenates the string representations of the elements in a specified System.Object array.
Declaration
public static StringSegment Concat(params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | args | An object array that contains the elements to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | The concatenated string representations of the values of the elements in args. |
Concat(StringSegment, StringSegment)
Concatenates two specified string segments.
Declaration
public static StringSegment Concat(StringSegment str0, StringSegment str1)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | str0 | The first string to concatenate. |
StringSegment | str1 | The second string to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | The concatenation of str0 and str1. |
Concat(StringSegment, StringSegment, StringSegment)
Concatenates three specified string segments.
Declaration
public static StringSegment Concat(StringSegment str0, StringSegment str1, StringSegment str2)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | str0 | The first string to concatenate. |
StringSegment | str1 | The second string to concatenate. |
StringSegment | str2 | The third string to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | The concatenation of str0, str1, and str2. |
Concat(StringSegment, StringSegment, StringSegment, StringSegment)
Concatenates four specified string segments.
Declaration
public static StringSegment Concat(StringSegment str0, StringSegment str1, StringSegment str2, StringSegment str3)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | str0 | The first string to concatenate. |
StringSegment | str1 | The second string to concatenate. |
StringSegment | str2 | The third string to concatenate. |
StringSegment | str3 | The fourth string to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | The concatenation of str0, str1, str2, and str3. |
Concat(StringSegment[])
Concatenates the elements of a specified string segment array.
Declaration
public static StringSegment Concat(params StringSegment[] values)
Parameters
Type | Name | Description |
---|---|---|
StringSegment[] | values | An array of string segments. |
Returns
Type | Description |
---|---|
StringSegment | The concatenated elements of values. |
Concat<T>(IEnumerable<T>)
Concatenates the members of an IEnumerable{T} implementation.
Declaration
public static StringSegment Concat<T>(IEnumerable<T> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | values | A collection object that implements the IEnumerable{T} interface. |
Returns
Type | Description |
---|---|
StringSegment | The concatenated members in values. |
Type Parameters
Name | Description |
---|---|
T | The type of the members of values. |
Contains(StringSegment)
Returns a value indicating whether a specified substring occurs within this string.
Declaration
public bool Contains(StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false. |
CopyTo(Int32, Char[], Int32, Int32)
Copies a specified number of characters from a specified position in this instance to a specified position in an array of Unicode characters.
Declaration
public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | sourceIndex | The index of the first character in this instance to copy. |
System.Char[] | destination | An array of Unicode characters to which characters in this instance are copied. |
System.Int32 | destinationIndex | The index in destination at which the copy operation begins. |
System.Int32 | count | The number of characters in this instance to copy to destination. |
EndsWith(StringSegment)
Determines whether the end of this string instance matches the specified string.
Declaration
public bool EndsWith(StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if value matches the end of this string segment; otherwise, false. |
EndsWith(StringSegment, Boolean, CultureInfo)
Determines whether the end of this string instance matches the specified string when compared using the specified culture.
Declaration
public bool EndsWith(StringSegment value, bool ignoreCase, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to compare. |
System.Boolean | ignoreCase | true to ignore case during the comparison; otherwise, false. |
System.Globalization.CultureInfo | culture | Cultural information that determines how this string and value are compared. If culture is null, the current culture is used. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value parameter matches the end of this string segment; otherwise, false. |
EndsWith(StringSegment, StringComparison)
Determines whether the end of this string instance matches the specified string when compared using the specified comparison option.
Declaration
public bool EndsWith(StringSegment value, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to compare. |
System.StringComparison | comparisonType | One of the enumeration values that determines how this string and value are compared. |
Returns
Type | Description |
---|---|
System.Boolean | true if this string segment ends with value; otherwise, false. |
Equals(Object)
Checks whether the string segment is equal to the specified object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare the string segment to. |
Returns
Type | Description |
---|---|
System.Boolean | true if the string segment is equal to the specified object; otherwise, false. |
Equals(StringSegment)
Checks whether the contents of the string segment are equal to the contents of the specified string segment.
Declaration
public bool Equals(StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string segment to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | true if the string segment is equal to the specified string segment; otherwise, false. |
Equals(StringSegment, StringComparison)
Determines whether this string and a specified string segment have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.
Declaration
public bool Equals(StringSegment value, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to compare to this instance. |
System.StringComparison | comparisonType | One of the enumeration values that specifies how the strings will be compared. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value of the value parameter is the same as this string; otherwise, false. |
Equals(StringSegment, StringSegment)
Determines whether two specified string segments have the same value.
Declaration
public static bool Equals(StringSegment a, StringSegment b)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | a | The first string to compare, or null. |
StringSegment | b | The second string to compare, or null. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value of a is the same as the value of b; otherwise, false. If both a and b are null, the method returns true. |
Equals(StringSegment, StringSegment, StringComparison)
Determines whether two specified string segments have the same value. A parameter specifies the culture, case, and sort rules used in the comparison.
Declaration
public static bool Equals(StringSegment a, StringSegment b, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | a | The first string to compare, or null. |
StringSegment | b | The second string to compare, or null. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules for the comparison. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value of the a parameter is equal to the value of the b parameter; otherwise, false. |
Format(IFormatProvider, StringSegment, Object[])
Replaces the format items in a specified string with the string representations of corresponding objects in a specified array. A parameter supplies culture-specific formatting information.
Declaration
public static StringSegment Format(IFormatProvider provider, StringSegment format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | provider | An object that supplies culture-specific formatting information. |
StringSegment | format | A composite format string. |
System.Object[] | args | An object array that contains zero or more objects to format. |
Returns
Type | Description |
---|---|
StringSegment | A copy of format in which the format items have been replaced by the string representation of the corresponding objects in args. |
Format(StringSegment, Object)
Replaces one or more format items in a specified string with the string representation of a specified object.
Declaration
public static StringSegment Format(StringSegment format, object arg0)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | format | A composite format string. |
System.Object | arg0 | The object to format. |
Returns
Type | Description |
---|---|
StringSegment | A copy of format in which any format items are replaced by the string representation of arg0. |
Format(StringSegment, Object, Object)
Replaces the format items in a specified string with the string representation of two specified objects.
Declaration
public static StringSegment Format(StringSegment format, object arg0, object arg1)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | format | A composite format string. |
System.Object | arg0 | The first object to format. |
System.Object | arg1 | The second object to format. |
Returns
Type | Description |
---|---|
StringSegment | A copy of format in which format items are replaced by the string representations of arg0 and arg1. |
Format(StringSegment, Object, Object, Object)
Replaces the format items in a specified string with the string representation of three specified objects.
Declaration
public static StringSegment Format(StringSegment format, object arg0, object arg1, object arg2)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | format | A composite format string. |
System.Object | arg0 | The first object to format. |
System.Object | arg1 | The second object to format. |
System.Object | arg2 | The third object to format. |
Returns
Type | Description |
---|---|
StringSegment | A copy of format in which the format items have been replaced by the string representations of arg0, arg1, and arg2. |
Format(StringSegment, Object[])
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.
Declaration
public static StringSegment Format(StringSegment format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | format | A composite format string. |
System.Object[] | args | An object array that contains zero or more objects to format. |
Returns
Type | Description |
---|---|
StringSegment | A copy of format in which the format items have been replaced by the string representation of the corresponding objects in args. |
GetEnumerator()
Retrieves an object that can iterate through the individual characters in this string.
Declaration
public StringSegmentCharEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
StringSegmentCharEnumerator | An enumerator object. |
GetHashCode()
Gets a hash code for the string segment.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | Hash code for the string segment. |
IndexOf(Char)
Reports the zero-based index of the first occurrence of the specified Unicode character in this string.
Declaration
public int IndexOf(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | A Unicode character to seek. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that character is found, or -1 if it is not. |
IndexOf(Char, Int32)
Reports the zero-based index of the first occurrence of the specified Unicode character in this string. The search starts at a specified character position.
Declaration
public int IndexOf(char value, int startIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | A Unicode character to seek. |
System.Int32 | startIndex | The search starting position. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that character is found, or -1 if it is not. |
IndexOf(Char, Int32, Int32)
Reports the zero-based index of the first occurrence of the specified character in this instance. The search starts at a specified character position and examines a specified number of character positions.
Declaration
public int IndexOf(char value, int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | A Unicode character to seek. |
System.Int32 | startIndex | The search starting position. |
System.Int32 | count | The number of character positions to examine. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that character is found, or -1 if it is not. |
IndexOf(StringSegment)
Reports the zero-based index of the first occurrence of the specified string in this instance.
Declaration
public int IndexOf(StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is 0. |
IndexOf(StringSegment, Int32)
Reports the zero-based index of the first occurrence of the specified string in this instance. The search starts at a specified character position.
Declaration
public int IndexOf(StringSegment value, int startIndex)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.Int32 | startIndex | The search starting position. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is startIndex. |
IndexOf(StringSegment, Int32, Int32)
Reports the zero-based index of the first occurrence of the specified character in this instance. The search starts at a specified character position and examines a specified number of character positions.
Declaration
public int IndexOf(StringSegment value, int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.Int32 | startIndex | The search starting position. |
System.Int32 | count | The number of character positions to examine. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is startIndex. |
IndexOf(StringSegment, Int32, Int32, StringComparison)
Reports the zero-based index of the first occurrence of the specified string in this instance. Parameters specify the starting search position in the current string, the number of characters in the current string to search, and the type of search to use for the specified string.
Declaration
public int IndexOf(StringSegment value, int startIndex, int count, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.Int32 | startIndex | The search starting position. |
System.Int32 | count | The number of character positions to examine. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules for the search. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is startIndex. |
IndexOf(StringSegment, Int32, StringComparison)
Reports the zero-based index of the first occurrence of the specified string in this instance. Parameters specify the starting search position in the current string and the type of search to use for the specified string.
Declaration
public int IndexOf(StringSegment value, int startIndex, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.Int32 | startIndex | The search starting position. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules for the search. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is startIndex. |
IndexOf(StringSegment, StringComparison)
Reports the zero-based index of the first occurrence of the specified string in this instance. A parameter specifies the type of search to use for the specified string.
Declaration
public int IndexOf(StringSegment value, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules for the search. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is 0. |
IndexOfAny(Char[])
Reports the zero-based index of the first occurrence in this instance of any character in a specified array of Unicode characters.
Declaration
public int IndexOfAny(char[] anyOf)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | anyOf | A Unicode character array containing one or more characters to seek. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of the first occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found. |
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.
Declaration
public int IndexOfAny(char[] anyOf, int startIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | anyOf | A Unicode character array containing one or more characters to seek. |
System.Int32 | startIndex | The search starting position. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of the first occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found. |
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.
Declaration
public int IndexOfAny(char[] anyOf, int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | anyOf | A Unicode character array containing one or more characters to seek. |
System.Int32 | startIndex | The search starting position. |
System.Int32 | count | The number of character positions to examine. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of the first occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found. |
Insert(Int32, StringSegment)
Returns a new string in which a specified string is inserted at a specified index position in this instance.
Declaration
public StringSegment Insert(int startIndex, StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The zero-based index position of the insertion. |
StringSegment | value | The string to insert. |
Returns
Type | Description |
---|---|
StringSegment | A new string that is equivalent to this instance, but with value inserted at position startIndex. |
IsNullOrEmpty(StringSegment)
Indicates whether the specified string is null or an empty string.
Declaration
public static bool IsNullOrEmpty(StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to test. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value parameter is null or an empty string (""); otherwise, false. |
IsNullOrWhiteSpace(StringSegment)
Indicates whether a specified string is null, empty, or consists only of white-space characters.
Declaration
public static bool IsNullOrWhiteSpace(StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to test. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value parameter is null or an empty string (""), or if value consists exclusively of white-space characters; otherwise, false. |
Join(StringSegment, IEnumerable<StringSegment>)
Concatenates the members of a constructed IEnumerable{T} of collection of string segments, using the specified separator between each member.
Declaration
public static StringSegment Join(StringSegment separator, IEnumerable<StringSegment> values)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | separator | The string to use as a separator. separator is included in the returned string only if values has more than one element. |
System.Collections.Generic.IEnumerable<StringSegment> | values | A collection that contains the strings to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | A string that consists of the members of values delimited by the separator string. If values has no members, the method returns Empty. |
Join(StringSegment, Object[])
Concatenates the elements of an object array, using the specified separator between each element.
Declaration
public static StringSegment Join(StringSegment separator, params object[] values)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | separator | The string to use as a separator. separator is included in the returned string only if values has more than one element. |
System.Object[] | values | An array that contains the elements to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | A string that consists of the elements of values delimited by the separator string. If values is an empty array, the method returns Empty. |
Join(StringSegment, StringSegment[])
Concatenates all the elements of a string array, using the specified separator between each element.
Declaration
public static StringSegment Join(StringSegment separator, params StringSegment[] value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | separator | The string to use as a separator. separator is included in the returned string only if value has more than one element. |
StringSegment[] | value | An array that contains the elements to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | A string that consists of the elements in value delimited by the separator string. If value is an empty array, the method returns Empty. |
Join(StringSegment, StringSegment[], Int32, Int32)
Concatenates the specified elements of a string array, using the specified separator between each element.
Declaration
public static StringSegment Join(StringSegment separator, StringSegment[] value, int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | separator | The string to use as a separator. separator is included in the returned string only if value has more than one element. |
StringSegment[] | value | An array that contains the elements to concatenate. |
System.Int32 | startIndex | The first element in value to use. |
System.Int32 | count | The number of elements of value to use. |
Returns
Type | Description |
---|---|
StringSegment | A string that consists of the strings in value delimited by the separator string -or- Empty if count is zero, value has no elements, or separator and all the elements of value are System.String.Empty.. |
Join<T>(StringSegment, IEnumerable<T>)
Concatenates the members of a collection, using the specified separator between each member.
Declaration
public static StringSegment Join<T>(StringSegment separator, IEnumerable<T> values)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | separator | The string to use as a separator. separator is included in the returned string only if values has more than one element. |
System.Collections.Generic.IEnumerable<T> | values | A collection that contains the objects to concatenate. |
Returns
Type | Description |
---|---|
StringSegment | A string that consists of the members of values delimited by the separator string. If values has no members, the method returns Empty. |
Type Parameters
Name | Description |
---|---|
T | The type of the members of values. |
LastIndexOf(Char)
Reports the zero-based index of the last occurrence of the specified Unicode character in this string.
Declaration
public int LastIndexOf(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | A Unicode character to seek. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that character is found, or -1 if it is not. |
LastIndexOf(Char, Int32)
Reports the zero-based index of the last occurrence of the specified Unicode character in this string. The search starts at a specified character position and proceeds backward toward the beginning of the string.
Declaration
public int LastIndexOf(char value, int startIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | A Unicode character to seek. |
System.Int32 | startIndex | The search starting position. The search proceeds from startIndex toward the beginning of this instance. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that character is found, or -1 if it is not found or if the current instance equals Empty. |
LastIndexOf(Char, Int32, Int32)
Reports the zero-based index of the last occurrence of the specified character in this instance. he search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.
Declaration
public int LastIndexOf(char value, int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | A Unicode character to seek. |
System.Int32 | startIndex | The search starting position. The search proceeds from startIndex toward the beginning of this instance. |
System.Int32 | count | The number of character positions to examine. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based index position of value if that character is found, or -1 if it is not found or if the current instance equals Empty. |
LastIndexOf(StringSegment)
Reports the zero-based index position of the last occurrence of a specified string within this instance.
Declaration
public int LastIndexOf(StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based starting index position of value if that string is found, or -1 if it is not. If value is Empty, the return value is the last index position in this instance. |
LastIndexOf(StringSegment, Int32)
Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string.
Declaration
public int LastIndexOf(StringSegment value, int startIndex)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.Int32 | startIndex | The search starting position. The search proceeds from startIndex toward the beginning of this instance. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based starting index position of value if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last index position in this instance. |
LastIndexOf(StringSegment, Int32, Int32)
Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.
Declaration
public int LastIndexOf(StringSegment value, int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.Int32 | startIndex | The search starting position. The search proceeds from startIndex toward the beginning of this instance. |
System.Int32 | count | The number of character positions to examine. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based starting index position of value if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last index position in this instance. |
LastIndexOf(StringSegment, Int32, Int32, StringComparison)
Reports the zero-based index position of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string for the specified number of character positions. A parameter specifies the type of comparison to perform when searching for the specified string.
Declaration
public int LastIndexOf(StringSegment value, int startIndex, int count, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.Int32 | startIndex | The search starting position. The search proceeds from startIndex toward the beginning of this instance. |
System.Int32 | count | The number of character positions to examine. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules for the search. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based starting index position of the value parameter if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last index position in this instance. |
LastIndexOf(StringSegment, Int32, StringComparison)
Reports the zero-based index of the last occurrence of a specified string within this instance. The search starts at a specified character position and proceeds backward toward the beginning of the string. A parameter specifies the type of comparison to perform when searching for the specified string.
Declaration
public int LastIndexOf(StringSegment value, int startIndex, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.Int32 | startIndex | The search starting position. The search proceeds from startIndex toward the beginning of this instance. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules for the search. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based starting index position of the value parameter if that string is found, or -1 if it is not found or if the current instance equals Empty. If value is Empty, the return value is the smaller of startIndex and the last index position in this instance. |
LastIndexOf(StringSegment, StringComparison)
Reports the zero-based index of the last occurrence of a specified string within this instance. A parameter specifies the type of search to use for the specified string.
Declaration
public int LastIndexOf(StringSegment value, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to seek. |
System.StringComparison | comparisonType | One of the enumeration values that specifies the rules for the search. |
Returns
Type | Description |
---|---|
System.Int32 | The zero-based starting index position of the value parameter if that string is found, or -1 if it is not. If value is Empty, the return value is the last index position in this instance. |
LastIndexOfAny(Char[])
Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array.
Declaration
public int LastIndexOfAny(char[] anyOf)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | anyOf | A Unicode character array containing one or more characters to seek. |
Returns
Type | Description |
---|---|
System.Int32 | The index position of the last occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found. |
LastIndexOfAny(Char[], Int32)
Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. The search starts at a specified character position and proceeds backward toward the beginning of the string.
Declaration
public int LastIndexOfAny(char[] anyOf, int startIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | anyOf | A Unicode character array containing one or more characters to seek. |
System.Int32 | startIndex | The search starting position. The search proceeds from startIndex toward the beginning of this instance. |
Returns
Type | Description |
---|---|
System.Int32 |
LastIndexOfAny(Char[], Int32, Int32)
Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.
Declaration
public int LastIndexOfAny(char[] anyOf, int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | anyOf | A Unicode character array containing one or more characters to seek. |
System.Int32 | startIndex | The search starting position. The search proceeds from startIndex toward the beginning of this instance. |
System.Int32 | count | The number of character positions to examine. |
Returns
Type | Description |
---|---|
System.Int32 | The index position of the last occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found or if the current instance equals Empty. |
PadLeft(Int32)
Returns a new string that right-aligns the characters in this instance by padding them with spaces on the left, for a specified total length.
Declaration
public StringSegment PadLeft(int totalWidth)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | totalWidth | The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters. |
Returns
Type | Description |
---|---|
StringSegment | A new string that is equivalent to this instance, but right-aligned and padded on the left with as many spaces as needed to create a length of totalWidth. However, if totalWidth is less than the length of this instance, the method returns a reference to the existing instance. |
PadLeft(Int32, Char)
Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a specified total length.
Declaration
public StringSegment PadLeft(int totalWidth, char paddingChar)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | totalWidth | The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters. |
System.Char | paddingChar | A Unicode padding character. |
Returns
Type | Description |
---|---|
StringSegment | A new string that is equivalent to this instance, but right-aligned and padded on the left with as many paddingChar characters as needed to create a length of totalWidth. However, if totalWidth is less than the length of this instance, the method returns a reference to the existing instance. |
PadRight(Int32)
Returns a new string that left-aligns the characters in this instance by padding them with spaces on the right, for a specified total length.
Declaration
public StringSegment PadRight(int totalWidth)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | totalWidth | The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters. |
Returns
Type | Description |
---|---|
StringSegment | A new string that is equivalent to this instance, but left-aligned and padded on the right with as many spaces as needed to create a length of totalWidth. However, if totalWidth is less than the length of this instance, the method returns a reference to the existing instance. |
PadRight(Int32, Char)
Returns a new string that left-aligns the characters in this instance by padding them on the right with a specified Unicode character, for a specified total length.
Declaration
public StringSegment PadRight(int totalWidth, char paddingChar)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | totalWidth | The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters. |
System.Char | paddingChar | A Unicode padding character. |
Returns
Type | Description |
---|---|
StringSegment | A new string that is equivalent to this instance, but left-aligned and padded on the right with as many paddingChar characters as needed to create a length of totalWidth. However, if totalWidth is less than the length of this instance, the method returns a reference to the existing instance. |
Remove(Int32)
Returns a new string in which all the characters in the current instance, beginning at a specified position and continuing through the last position, have been deleted.
Declaration
public StringSegment Remove(int startIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The zero-based position to begin deleting characters. |
Returns
Type | Description |
---|---|
StringSegment | A new string that is equivalent to this string except for the removed characters. |
Remove(Int32, Int32)
Returns a new string in which a specified number of characters in the current instance beginning at a specified position have been deleted.
Declaration
public StringSegment Remove(int startIndex, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The zero-based position to begin deleting characters. |
System.Int32 | count | The number of characters to delete. |
Returns
Type | Description |
---|---|
StringSegment | A new string that is equivalent to this instance except for the removed characters. |
Replace(Char, Char)
Returns a new string in which all occurrences of a specified Unicode character in this instance are replaced with another specified Unicode character.
Declaration
public StringSegment Replace(char oldChar, char newChar)
Parameters
Type | Name | Description |
---|---|---|
System.Char | oldChar | The Unicode character to be replaced. |
System.Char | newChar | The Unicode character to replace all occurrences of oldChar. |
Returns
Type | Description |
---|---|
StringSegment | A string that is equivalent to this instance except that all instances of oldChar are replaced with newChar. If oldChar is not found in the current instance, the method returns the current instance unchanged. |
Replace(StringSegment, StringSegment)
Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.
Declaration
public StringSegment Replace(StringSegment oldValue, StringSegment newValue)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | oldValue | The string to be replaced. |
StringSegment | newValue | The string to replace all occurrences of oldValue. |
Returns
Type | Description |
---|---|
StringSegment | A string that is equivalent to the current string except that all instances of oldValue are replaced with newValue. If oldValue is not found in the current instance, the method returns the current instance unchanged. |
Split(Char[])
Splits a string into substrings that are based on the characters in an array.
Declaration
public StringSegment[] Split(params char[] separator)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | separator | A character array that delimits the substrings in this string, an empty array that contains no delimiters, or null. |
Returns
Type | Description |
---|---|
StringSegment[] | An array whose elements contain the substrings from this instance that are delimited by one or more characters in separator. |
Split(Char[], Int32)
Splits a string into a maximum number of substrings based on the characters in an array. You also specify the maximum number of substrings to return.
Declaration
public StringSegment[] Split(char[] separator, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | separator | A character array that delimits the substrings in this string, an empty array that contains no delimiters, or null. |
System.Int32 | count | The maximum number of substrings to return. |
Returns
Type | Description |
---|---|
StringSegment[] | An array whose elements contain the substrings in this instance that are delimited by one or more characters in separator. |
Split(Char[], Int32, StringSplitOptions)
Splits a string into a maximum number of substrings based on the characters in an array. You can specify whether the substrings include empty array elements.
Declaration
public StringSegment[] Split(char[] separator, int count, StringSplitOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | separator | A character array that delimits the substrings in this string, an empty array that contains no delimiters, or null. |
System.Int32 | count | The maximum number of substrings to return. |
System.StringSplitOptions | options | StringSplitOptions.RemoveEmptyEntries to omit empty array elements from the array returned; or StringSplitOptions.None to include empty array elements in the array returned. |
Returns
Type | Description |
---|---|
StringSegment[] | An array whose elements contain the substrings in this string that are delimited by one or more characters in separator. |
Split(Char[], StringSplitOptions)
Splits a string into substrings based on the characters in an array. You can specify whether the substrings include empty array elements.
Declaration
public StringSegment[] Split(char[] separator, StringSplitOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | separator | A character array that delimits the substrings in this string, an empty array that contains no delimiters, or null. |
System.StringSplitOptions | options | StringSplitOptions.RemoveEmptyEntries to omit empty array elements from the array returned; or StringSplitOptions.None to include empty array elements in the array returned. |
Returns
Type | Description |
---|---|
StringSegment[] | An array whose elements contain the substrings in this string that are delimited by one or more characters in separator. |
Split(StringSegment[], Int32, StringSplitOptions)
Splits a string into a maximum number of substrings based on the strings in an array. You can specify whether the substrings include empty array elements.
Declaration
public StringSegment[] Split(StringSegment[] separator, int count, StringSplitOptions options)
Parameters
Type | Name | Description |
---|---|---|
StringSegment[] | separator | A string array that delimits the substrings in this string, an empty array that contains no delimiters, or null. |
System.Int32 | count | The maximum number of substrings to return. |
System.StringSplitOptions | options | StringSplitOptions.RemoveEmptyEntries to omit empty array elements from the array returned; or StringSplitOptions.None to include empty array elements in the array returned. |
Returns
Type | Description |
---|---|
StringSegment[] | An array whose elements contain the substrings in this string that are delimited by one or more strings in separator. |
Split(StringSegment[], StringSplitOptions)
Splits a string into substrings based on the strings in an array. You can specify whether the substrings include empty array elements.
Declaration
public StringSegment[] Split(StringSegment[] separator, StringSplitOptions options)
Parameters
Type | Name | Description |
---|---|---|
StringSegment[] | separator | A string array that delimits the substrings in this string, an empty array that contains no delimiters, or null. |
System.StringSplitOptions | options | StringSplitOptions.RemoveEmptyEntries to omit empty array elements from the array returned; or StringSplitOptions.None to include empty array elements in the array returned. |
Returns
Type | Description |
---|---|
StringSegment[] | An array whose elements contain the substrings in this string that are delimited by one or more strings in separator. |
StartsWith(StringSegment)
Determines whether the beginning of this string instance matches the specified string.
Declaration
public bool StartsWith(StringSegment value)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to compare. |
Returns
Type | Description |
---|---|
System.Boolean | true if value matches the beginning of this string segment; otherwise, false. |
StartsWith(StringSegment, Boolean, CultureInfo)
Determines whether the beginning of this string instance matches the specified string when compared using the specified culture.
Declaration
public bool StartsWith(StringSegment value, bool ignoreCase, CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to compare. |
System.Boolean | ignoreCase | true to ignore case during the comparison; otherwise, false. |
System.Globalization.CultureInfo | culture | Cultural information that determines how this string and value are compared. If culture is null, the current culture is used. |
Returns
Type | Description |
---|---|
System.Boolean | true if the value parameter matches the beginning of this string segment; otherwise, false. |
StartsWith(StringSegment, StringComparison)
Determines whether the beginning of this string instance matches the specified string when compared using the specified comparison option.
Declaration
public bool StartsWith(StringSegment value, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | value | The string to compare. |
System.StringComparison | comparisonType | One of the enumeration values that determines how this string and value are compared. |
Returns
Type | Description |
---|---|
System.Boolean | true if this string segment begins with value; otherwise, false. |
Substring(Int32)
Retrieves a substring from this instance. The substring starts at a specified character position and continues to the end of the string.
Declaration
public StringSegment Substring(int startIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The zero-based starting character position of a substring in this instance. |
Returns
Type | Description |
---|---|
StringSegment | A string that is equivalent to the substring that begins at startIndex in this instance, or Empty if startIndex is equal to the length of this instance. |
Substring(Int32, Int32)
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
Declaration
public StringSegment Substring(int startIndex, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The zero-based starting character position of a substring in this instance. |
System.Int32 | length | The number of characters in the substring. |
Returns
Type | Description |
---|---|
StringSegment | A string that is equivalent to the substring of length length that begins at startIndex in this instance, or Empty if startIndex is equal to the length of this instance and length is zero. |
ToCharArray()
Copies the characters in this instance to a Unicode character array.
Declaration
public char[] ToCharArray()
Returns
Type | Description |
---|---|
System.Char[] | A Unicode character array whose elements are the individual characters of this instance. If this instance is an empty string, the returned array is empty and has a zero length. |
ToCharArray(Int32, Int32)
Copies the characters in a specified substring in this instance to a Unicode character array.
Declaration
public char[] ToCharArray(int startIndex, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The starting position of a substring in this instance. |
System.Int32 | length | The length of the substring in this instance. |
Returns
Type | Description |
---|---|
System.Char[] | A Unicode character array whose elements are the length number of characters in this instance starting from character position startIndex. |
ToLower()
Returns a copy of this string converted to lowercase.
Declaration
public StringSegment ToLower()
Returns
Type | Description |
---|---|
StringSegment | A string in lowercase. |
ToLower(CultureInfo)
Returns a copy of this string converted to lowercase, using the casing rules of the specified culture.
Declaration
public StringSegment ToLower(CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | An object that supplies culture-specific casing rules. |
Returns
Type | Description |
---|---|
StringSegment | The lowercase equivalent of the current string. |
ToLowerInvariant()
Returns a copy of this System.String object converted to lowercase using the casing rules of the invariant culture.
Declaration
public StringSegment ToLowerInvariant()
Returns
Type | Description |
---|---|
StringSegment | The lowercase equivalent of the current string. |
ToString()
Gets a string representing the contents of the string segment. This method may cause object allocation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String representing the contents of the string segment. |
ToString(IFormatProvider)
Gets a string representing the contents of the string segment. This method may cause object allocation.
Declaration
public string ToString(IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | provider | (Reserved) An object that supplies culture-specific formatting information. |
Returns
Type | Description |
---|---|
System.String | String representing the contents of the string segment. |
ToUpper()
Returns a copy of this string converted to uppercase.
Declaration
public StringSegment ToUpper()
Returns
Type | Description |
---|---|
StringSegment | The uppercase equivalent of the current string. |
ToUpper(CultureInfo)
Returns a copy of this string converted to uppercase, using the casing rules of the specified culture.
Declaration
public StringSegment ToUpper(CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | An object that supplies culture-specific casing rules. |
Returns
Type | Description |
---|---|
StringSegment | The uppercase equivalent of the current string. |
ToUpperInvariant()
Returns a copy of this System.String object converted to uppercase using the casing rules of the invariant culture.
Declaration
public StringSegment ToUpperInvariant()
Returns
Type | Description |
---|---|
StringSegment | The uppercase equivalent of the current string. |
Trim()
Removes all leading and trailing white-space characters from the current System.String object.
Declaration
public StringSegment Trim()
Returns
Type | Description |
---|---|
StringSegment | The string that remains after all white-space characters are removed from the start and end of the current string. If no characters can be trimmed from the current instance, the method returns the current instance unchanged. |
Trim(Char[])
Removes all leading and trailing occurrences of a set of characters specified in an array from the current System.String object.
Declaration
public StringSegment Trim(params char[] trimChars)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | trimChars | An array of Unicode characters to remove, or null. |
Returns
Type | Description |
---|---|
StringSegment | The string that remains after all occurrences of the characters in the trimChars parameter are removed from the start and end of the current string. If trimChars is null or an empty array, white-space characters are removed instead. If no characters can be trimmed from the current instance, the method returns the current instance unchanged. |
TrimEnd(Char[])
Removes all trailing occurrences of a set of characters specified in an array from the current System.String object.
Declaration
public StringSegment TrimEnd(params char[] trimChars)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | trimChars | An array of Unicode characters to remove, or null. |
Returns
Type | Description |
---|---|
StringSegment | The string that remains after all occurrences of the characters in the trimChars parameter are removed from the end of the current string. If trimChars is null or an empty array, Unicode white-space characters are removed instead. If no characters can be trimmed from the current instance, the method returns the current instance unchanged. |
TrimStart(Char[])
Removes all leading occurrences of a set of characters specified in an array from the current System.String object.
Declaration
public StringSegment TrimStart(params char[] trimChars)
Parameters
Type | Name | Description |
---|---|---|
System.Char[] | trimChars | An array of Unicode characters to remove, or null. |
Returns
Type | Description |
---|---|
StringSegment | The string that remains after all occurrences of characters in the trimChars parameter are removed from the start of the current string. If trimChars is null or an empty array, white-space characters are removed instead. If no characters can be trimmed from the current instance, the method returns the current instance unchanged. |
Operators
Equality(StringSegment, StringSegment)
Checks whether the specified string segments are equal.
Declaration
public static bool operator ==(StringSegment a, StringSegment b)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | a | The first string segment to compare for equality. |
StringSegment | b | The second string segment to compare for equality. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified string segments are equal; otherwise, false. |
Explicit(StringSegment to String)
Explicit conversion from StringSegment to String. This method may cause object allocation.
Declaration
public static explicit operator string (StringSegment segment)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | segment | The string segment to convert to a string. |
Returns
Type | Description |
---|---|
System.String |
Implicit(String to StringSegment)
Implicit conversion from String to StringSegment.
Declaration
public static implicit operator StringSegment(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The string to convert to a string segment. |
Returns
Type | Description |
---|---|
StringSegment |
Inequality(StringSegment, StringSegment)
Checks whether the specified string segments are not equal.
Declaration
public static bool operator !=(StringSegment a, StringSegment b)
Parameters
Type | Name | Description |
---|---|---|
StringSegment | a | The first string segment to compare for inequality. |
StringSegment | b | The second string segment to compare for inequality. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified string segments are not equal; otherwise, false. |