Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Globalization.​CompareInfo

Assembly: System.Runtime

Inheritance: object → CompareInfo

Implemented Interfaces

Implements a set of methods for culture-sensitive string comparisons.

Properties

public int
LCID
Gets the properly formed culture identifier for the current <see cref="T:System.Globalization.CompareInfo" /> .
public string
Name
Gets the name of the culture used for sorting operations by this <see cref="T:System.Globalization.CompareInfo" /> object.
public SortVersion
Version
Gets information about the version of Unicode used for comparing and sorting strings.

Methods

public int
Compare​(ReadOnlySpan<​char> string1, ReadOnlySpan<​char> string2, CompareOptions options = 0)
Compares two read-only spans of characters.
Returns Zero if <paramref name="string1" /> and <paramref name="string2" /> are equal; or a negative value if <paramref name="string1" /> sorts before <paramref name="string2" /> ; or a positive value if <paramref name="string1" /> sorts after <paramref name="string2" /> .
string1 The first read-only span of characters to compare.
string2 The second read-only span of characters to compare.
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use during the comparison. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public int
Compare​(string string1, int offset1, int length1, string string2, int offset2, int length2)
Compares a section of one string with a section of another string.
Returns A 32-bit signed integer indicating the lexical relationship between the two comparands. <list type="table"> <listheader> <term> Value</term> <description> Condition</description> </listheader> <item> <term> zero</term> <description> The two strings are equal.</description> </item> <item> <term> less than zero</term> <description> The specified section of <paramref name="string1" /> is less than the specified section of <paramref name="string2" />.</description> </item> <item> <term> greater than zero</term> <description> The specified section of <paramref name="string1" /> is greater than the specified section of <paramref name="string2" />.</description> </item> </list>
string1 The first string to compare.
offset1 The zero-based index of the character in <paramref name="string1" /> at which to start comparing.
length1 The number of consecutive characters in <paramref name="string1" /> to compare.
string2 The second string to compare.
offset2 The zero-based index of the character in <paramref name="string2" /> at which to start comparing.
length2 The number of consecutive characters in <paramref name="string2" /> to compare.
public int
Compare​(string string1, int offset1, int length1, string string2, int offset2, int length2, CompareOptions options)
Compares a section of one string with a section of another string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns A 32-bit signed integer indicating the lexical relationship between the two comparands. <list type="table"> <listheader> <term> Value</term> <description> Condition</description> </listheader> <item> <term> zero</term> <description> The two strings are equal.</description> </item> <item> <term> less than zero</term> <description> The specified section of <paramref name="string1" /> is less than the specified section of <paramref name="string2" />.</description> </item> <item> <term> greater than zero</term> <description> The specified section of <paramref name="string1" /> is greater than the specified section of <paramref name="string2" />.</description> </item> </list>
string1 The first string to compare.
offset1 The zero-based index of the character in <paramref name="string1" /> at which to start comparing.
length1 The number of consecutive characters in <paramref name="string1" /> to compare.
string2 The second string to compare.
offset2 The zero-based index of the character in <paramref name="string2" /> at which to start comparing.
length2 The number of consecutive characters in <paramref name="string2" /> to compare.
options A value that defines how <paramref name="string1" /> and <paramref name="string2" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> , and <see cref="F:System.Globalization.CompareOptions.StringSort" /> .
public int
Compare​(string string1, int offset1, string string2, int offset2)
Compares the end section of a string with the end section of another string.
Returns A 32-bit signed integer indicating the lexical relationship between the two comparands. <list type="table"> <listheader> <term> Value</term> <description> Condition</description> </listheader> <item> <term> zero</term> <description> The two strings are equal.</description> </item> <item> <term> less than zero</term> <description> The specified section of <paramref name="string1" /> is less than the specified section of <paramref name="string2" />.</description> </item> <item> <term> greater than zero</term> <description> The specified section of <paramref name="string1" /> is greater than the specified section of <paramref name="string2" />.</description> </item> </list>
string1 The first string to compare.
offset1 The zero-based index of the character in <paramref name="string1" /> at which to start comparing.
string2 The second string to compare.
offset2 The zero-based index of the character in <paramref name="string2" /> at which to start comparing.
public int
Compare​(string string1, int offset1, string string2, int offset2, CompareOptions options)
Compares the end section of a string with the end section of another string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns A 32-bit signed integer indicating the lexical relationship between the two comparands. <list type="table"> <listheader> <term> Value</term> <description> Condition</description> </listheader> <item> <term> zero</term> <description> The two strings are equal.</description> </item> <item> <term> less than zero</term> <description> The specified section of <paramref name="string1" /> is less than the specified section of <paramref name="string2" />.</description> </item> <item> <term> greater than zero</term> <description> The specified section of <paramref name="string1" /> is greater than the specified section of <paramref name="string2" />.</description> </item> </list>
string1 The first string to compare.
offset1 The zero-based index of the character in <paramref name="string1" /> at which to start comparing.
string2 The second string to compare.
offset2 The zero-based index of the character in <paramref name="string2" /> at which to start comparing.
options A value that defines how <paramref name="string1" /> and <paramref name="string2" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> , and <see cref="F:System.Globalization.CompareOptions.StringSort" /> .
public int
Compare​(string string1, string string2)
Compares two strings.
Returns A 32-bit signed integer indicating the lexical relationship between the two comparands. <list type="table"> <listheader> <term> Value</term> <description> Condition</description> </listheader> <item> <term> zero</term> <description> The two strings are equal.</description> </item> <item> <term> less than zero</term> <description> <paramref name="string1" /> is less than <paramref name="string2" />.</description> </item> <item> <term> greater than zero</term> <description> <paramref name="string1" /> is greater than <paramref name="string2" />.</description> </item> </list>
string1 The first string to compare.
string2 The second string to compare.
public int
Compare​(string string1, string string2, CompareOptions options)
Compares two strings using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns A 32-bit signed integer indicating the lexical relationship between the two comparands. <list type="table"> <listheader> <term> Value</term> <description> Condition</description> </listheader> <item> <term> zero</term> <description> The two strings are equal.</description> </item> <item> <term> less than zero</term> <description> <paramref name="string1" /> is less than <paramref name="string2" />.</description> </item> <item> <term> greater than zero</term> <description> <paramref name="string1" /> is greater than <paramref name="string2" />.</description> </item> </list>
string1 The first string to compare.
string2 The second string to compare.
options A value that defines how <paramref name="string1" /> and <paramref name="string2" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> , and <see cref="F:System.Globalization.CompareOptions.StringSort" /> .
public bool
Equals​(object value)
Determines whether the specified object is equal to the current <see cref="T:System.Globalization.CompareInfo" /> object.
Returns <see langword="true" /> if the specified object is equal to the current <see cref="T:System.Globalization.CompareInfo" /> ; otherwise, <see langword="false" /> .
value The object to compare with the current <see cref="T:System.Globalization.CompareInfo" /> .
public static CompareInfo
GetCompareInfo​(int culture)
Initializes a new <see cref="T:System.Globalization.CompareInfo" /> object that is associated with the culture with the specified identifier.
Returns A new <see cref="T:System.Globalization.CompareInfo" /> object associated with the culture with the specified identifier and using string comparison methods in the current <see cref="T:System.Reflection.Assembly" /> .
culture An integer representing the culture identifier.
public static CompareInfo
GetCompareInfo​(int culture, Reflection.​Assembly assembly)
Initializes a new <see cref="T:System.Globalization.CompareInfo" /> object that is associated with the specified culture and that uses string comparison methods in the specified <see cref="T:System.Reflection.Assembly" /> .
Returns A new <see cref="T:System.Globalization.CompareInfo" /> object associated with the culture with the specified identifier and using string comparison methods in the current <see cref="T:System.Reflection.Assembly" /> .
culture An integer representing the culture identifier.
assembly An <see cref="T:System.Reflection.Assembly" /> that contains the string comparison methods to use.
public static CompareInfo
GetCompareInfo​(string name)
Initializes a new <see cref="T:System.Globalization.CompareInfo" /> object that is associated with the culture with the specified name.
Returns A new <see cref="T:System.Globalization.CompareInfo" /> object associated with the culture with the specified identifier and using string comparison methods in the current <see cref="T:System.Reflection.Assembly" /> .
name A string representing the culture name.
public static CompareInfo
GetCompareInfo​(string name, Reflection.​Assembly assembly)
Initializes a new <see cref="T:System.Globalization.CompareInfo" /> object that is associated with the specified culture and that uses string comparison methods in the specified <see cref="T:System.Reflection.Assembly" /> .
Returns A new <see cref="T:System.Globalization.CompareInfo" /> object associated with the culture with the specified identifier and using string comparison methods in the current <see cref="T:System.Reflection.Assembly" /> .
name A string representing the culture name.
assembly An <see cref="T:System.Reflection.Assembly" /> that contains the string comparison methods to use.
public int
GetHashCode​()
Serves as a hash function for the current <see cref="T:System.Globalization.CompareInfo" /> for hashing algorithms and data structures, such as a hash table.
Returns A hash code for the current <see cref="T:System.Globalization.CompareInfo" /> .
public int
GetHashCode​(ReadOnlySpan<​char> source, CompareOptions options)
Gets the hash code for a character span based on specified comparison options.
Returns A 32-bit signed integer hash code.
source The character span whose hash code is to be returned.
options A value that determines how strings are compared.
public int
GetHashCode​(string source, CompareOptions options)
Gets the hash code for a string based on specified comparison options.
Returns A 32-bit signed integer hash code.
source The string whose hash code is to be returned.
options A value that determines how strings are compared.
public int
GetSortKey​(ReadOnlySpan<​char> source, Span<​byte> destination, CompareOptions options = 0)
Computes a sort key for the specified input.
Returns The number of bytes written to <paramref name="destination" /> .
source The text to get the sort key for.
destination The buffer into which the resulting sort key bytes are stored.
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use for computing the sort key. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public SortKey
GetSortKey​(string source)
Gets the sort key for the specified string.
Returns The <see cref="T:System.Globalization.SortKey" /> object that contains the sort key for the specified string.
source The string for which a <see cref="T:System.Globalization.SortKey" /> object is obtained.
public SortKey
GetSortKey​(string source, CompareOptions options)
Gets a <see cref="T:System.Globalization.SortKey" /> object for the specified string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The <see cref="T:System.Globalization.SortKey" /> object that contains the sort key for the specified string.
source The string for which a <see cref="T:System.Globalization.SortKey" /> object is obtained.
options A bitwise combination of one or more of the following enumeration values that define how the sort key is calculated: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> , and <see cref="F:System.Globalization.CompareOptions.StringSort" /> .
public int
GetSortKeyLength​(ReadOnlySpan<​char> source, CompareOptions options = 0)
Gets the total number of sort key bytes that would be produced from the specified input.
Returns The length, in bytes, of the sort key.
source The text to get the sort key for.
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use for computing the sort key. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public int
IndexOf​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> value, CompareOptions options = 0)
Searches for the first occurrence of a substring within the specified read-only span of characters.
Returns The zero-based index into <paramref name="source" /> where the substring <paramref name="value" /> first appears; or a negative value if <paramref name="value" /> cannot be found within <paramref name="source" /> .
source The string to search within.
value The substring to locate within <paramref name="source" /> .
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use during the search. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public int
IndexOf​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> value, CompareOptions options, Int32& matchLength)
public int
IndexOf​(ReadOnlySpan<​char> source, Text.​Rune value, CompareOptions options = 0)
Searches for the first occurrence of a <see cref="T:System.Text.Rune" /> within the specified read-only span of characters.
Returns The zero-based index into <paramref name="source" /> where <paramref name="value" /> first appears; or a negative value if <paramref name="value" /> cannot be found within <paramref name="source" /> .
source The read-only span of characters to search within.
value The <see cref="T:System.Text.Rune" /> to locate within <paramref name="source" /> .
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use during the search. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public int
IndexOf​(string source, char value)
Searches for the specified character and returns the zero-based index of the first occurrence within the entire source string.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within <paramref name="source" /> ; otherwise, -1. Returns 0 (zero) if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
public int
IndexOf​(string source, char value, CompareOptions options)
Searches for the specified character and returns the zero-based index of the first occurrence within the entire source string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within <paramref name="source" /> , using the specified comparison options; otherwise, -1. Returns 0 (zero) if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
options A value that defines how the strings should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
IndexOf​(string source, char value, int startIndex)
Searches for the specified character and returns the zero-based index of the first occurrence within the section of the source string that extends from the specified index to the end of the string.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that extends from <paramref name="startIndex" /> to the end of <paramref name="source" /> ; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the search.
public int
IndexOf​(string source, char value, int startIndex, CompareOptions options)
Searches for the specified character and returns the zero-based index of the first occurrence within the section of the source string that extends from the specified index to the end of the string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that extends from <paramref name="startIndex" /> to the end of <paramref name="source" /> , using the specified comparison options; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the search.
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
IndexOf​(string source, char value, int startIndex, int count)
Searches for the specified character and returns the zero-based index of the first occurrence within the section of the source string that starts at the specified index and contains the specified number of elements.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that starts at <paramref name="startIndex" /> and contains the number of elements specified by <paramref name="count" /> ; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the search.
count The number of elements in the section to search.
public int
IndexOf​(string source, char value, int startIndex, int count, CompareOptions options)
Searches for the specified character and returns the zero-based index of the first occurrence within the section of the source string that starts at the specified index and contains the specified number of elements using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that starts at <paramref name="startIndex" /> and contains the number of elements specified by <paramref name="count" /> , using the specified comparison options; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the search.
count The number of elements in the section to search.
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
IndexOf​(string source, string value)
Searches for the specified substring and returns the zero-based index of the first occurrence within the entire source string.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within <paramref name="source" /> ; otherwise, -1. Returns 0 (zero) if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
public int
IndexOf​(string source, string value, CompareOptions options)
Searches for the specified substring and returns the zero-based index of the first occurrence within the entire source string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within <paramref name="source" /> , using the specified comparison options; otherwise, -1. Returns 0 (zero) if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
IndexOf​(string source, string value, int startIndex)
Searches for the specified substring and returns the zero-based index of the first occurrence within the section of the source string that extends from the specified index to the end of the string.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that extends from <paramref name="startIndex" /> to the end of <paramref name="source" /> ; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the search.
public int
IndexOf​(string source, string value, int startIndex, CompareOptions options)
Searches for the specified substring and returns the zero-based index of the first occurrence within the section of the source string that extends from the specified index to the end of the string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that extends from <paramref name="startIndex" /> to the end of <paramref name="source" /> , using the specified comparison options; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the search.
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
IndexOf​(string source, string value, int startIndex, int count)
Searches for the specified substring and returns the zero-based index of the first occurrence within the section of the source string that starts at the specified index and contains the specified number of elements.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that starts at <paramref name="startIndex" /> and contains the number of elements specified by <paramref name="count" /> ; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the search.
count The number of elements in the section to search.
public int
IndexOf​(string source, string value, int startIndex, int count, CompareOptions options)
Searches for the specified substring and returns the zero-based index of the first occurrence within the section of the source string that starts at the specified index and contains the specified number of elements using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the first occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that starts at <paramref name="startIndex" /> and contains the number of elements specified by <paramref name="count" /> , using the specified comparison options; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the search.
count The number of elements in the section to search.
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public bool
IsPrefix​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> prefix, CompareOptions options = 0)
Determines whether a read-only span of characters starts with a specific prefix.
Returns <see langword="true" /> if <paramref name="prefix" /> occurs at the start of <paramref name="source" /> ; otherwise, <see langword="false" /> .
source The read-only span of characters to search within.
prefix The prefix to attempt to match at the start of <paramref name="source" /> .
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use during the match. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public bool
IsPrefix​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> prefix, CompareOptions options, Int32& matchLength)
public bool
IsPrefix​(string source, string prefix)
Determines whether the specified source string starts with the specified prefix.
Returns <see langword="true" /> if the length of <paramref name="prefix" /> is less than or equal to the length of <paramref name="source" /> and <paramref name="source" /> starts with <paramref name="prefix" /> ; otherwise, <see langword="false" /> .
source The string to search in.
prefix The string to compare with the beginning of <paramref name="source" /> .
public bool
IsPrefix​(string source, string prefix, CompareOptions options)
Determines whether the specified source string starts with the specified prefix using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns <see langword="true" /> if the length of <paramref name="prefix" /> is less than or equal to the length of <paramref name="source" /> and <paramref name="source" /> starts with <paramref name="prefix" /> ; otherwise, <see langword="false" /> .
source The string to search in.
prefix The string to compare with the beginning of <paramref name="source" /> .
options A value that defines how <paramref name="source" /> and <paramref name="prefix" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public static bool
IsSortable​(char ch)
Indicates whether a specified Unicode character is sortable.
Returns <see langword="true" /> if the <paramref name="ch" /> parameter is sortable; otherwise, <see langword="false" /> .
ch A Unicode character.
public static bool
IsSortable​(ReadOnlySpan<​char> text)
Indicates whether a specified Unicode read-only span of characters is sortable.
Returns <see langword="true" /> if <paramref name="text" /> is non-empty and contains only sortable Unicode characters; otherwise, <see langword="false" /> .
text A read-only span of characters of zero or more Unicode characters.
public static bool
IsSortable​(string text)
Indicates whether a specified Unicode string is sortable.
Returns <see langword="true" /> if the <paramref name="text" /> parameter is not an empty string ("") and all the Unicode characters in <paramref name="text" /> are sortable; otherwise, <see langword="false" /> .
text A string of zero or more Unicode characters.
public static bool
IsSortable​(Text.​Rune value)
Indicates whether a specified <see cref="T:System.Text.Rune" /> is sortable.
Returns <see langword="true" /> if <paramref name="value" /> is a sortable Unicode scalar value; otherwise, <see langword="false" /> .
value A Unicode scalar value.
public bool
IsSuffix​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> suffix, CompareOptions options = 0)
Determines whether a read-only span of characters ends with a specific suffix.
Returns <see langword="true" /> if <paramref name="suffix" /> occurs at the end of <paramref name="source" /> ; otherwise, <see langword="false" /> .
source The read-only span of characters to search within.
suffix The suffix to attempt to match at the end of <paramref name="source" /> .
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use during the match. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public bool
IsSuffix​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> suffix, CompareOptions options, Int32& matchLength)
public bool
IsSuffix​(string source, string suffix)
Determines whether the specified source string ends with the specified suffix.
Returns <see langword="true" /> if the length of <paramref name="suffix" /> is less than or equal to the length of <paramref name="source" /> and <paramref name="source" /> ends with <paramref name="suffix" /> ; otherwise, <see langword="false" /> .
source The string to search in.
suffix The string to compare with the end of <paramref name="source" /> .
public bool
IsSuffix​(string source, string suffix, CompareOptions options)
Determines whether the specified source string ends with the specified suffix using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns <see langword="true" /> if the length of <paramref name="suffix" /> is less than or equal to the length of <paramref name="source" /> and <paramref name="source" /> ends with <paramref name="suffix" /> ; otherwise, <see langword="false" /> .
source The string to search in.
suffix The string to compare with the end of <paramref name="source" /> .
options A value that defines how <paramref name="source" /> and <paramref name="suffix" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> used by itself, or the bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
LastIndexOf​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> value, CompareOptions options = 0)
Searches for the last occurrence of a substring within the specified read-only span of characters.
Returns The zero-based index into <paramref name="source" /> where the substring <paramref name="value" /> last appears; or a negative value if <paramref name="value" /> cannot be found within <paramref name="source" /> .
source The read-only span of characters to search within.
value The substring to locate within <paramref name="source" /> .
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use during the search. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public int
LastIndexOf​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> value, CompareOptions options, Int32& matchLength)
public int
LastIndexOf​(ReadOnlySpan<​char> source, Text.​Rune value, CompareOptions options = 0)
Searches for the last occurrence of a <see cref="T:System.Text.Rune" /> within the specified read-only span of characters.
Returns The zero-based index into <paramref name="source" /> where <paramref name="value" /> last appears; or a negative value if <paramref name="value" /> cannot be found within <paramref name="source" /> .
source The read-only span of characters to search within.
value The <see cref="T:System.Text.Rune" /> to locate within <paramref name="source" /> .
options An optional combination of <see cref="T:System.Globalization.CompareOptions" /> enumeration values to use during the search. The default value is <see cref="F:System.Globalization.CompareOptions.None" /> .
public int
LastIndexOf​(string source, char value)
Searches for the specified character and returns the zero-based index of the last occurrence within the entire source string.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within <paramref name="source" /> ; otherwise, -1.
source The string to search.
value The character to locate within <paramref name="source" /> .
public int
LastIndexOf​(string source, char value, CompareOptions options)
Searches for the specified character and returns the zero-based index of the last occurrence within the entire source string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within <paramref name="source" /> , using the specified comparison options; otherwise, -1.
source The string to search.
value The character to locate within <paramref name="source" /> .
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
LastIndexOf​(string source, char value, int startIndex)
Searches for the specified character and returns the zero-based index of the last occurrence within the section of the source string that extends from the beginning of the string to the specified index.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that extends from the beginning of <paramref name="source" /> to <paramref name="startIndex" /> ; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the backward search.
public int
LastIndexOf​(string source, char value, int startIndex, CompareOptions options)
Searches for the specified character and returns the zero-based index of the last occurrence within the section of the source string that extends from the beginning of the string to the specified index using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that extends from the beginning of <paramref name="source" /> to <paramref name="startIndex" /> , using the specified comparison options; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the backward search.
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
LastIndexOf​(string source, char value, int startIndex, int count)
Searches for the specified character and returns the zero-based index of the last occurrence within the section of the source string that contains the specified number of elements and ends at the specified index.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that contains the number of elements specified by <paramref name="count" /> and that ends at <paramref name="startIndex" /> ; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the backward search.
count The number of elements in the section to search.
public int
LastIndexOf​(string source, char value, int startIndex, int count, CompareOptions options)
Searches for the specified character and returns the zero-based index of the last occurrence within the section of the source string that contains the specified number of elements and ends at the specified index using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that contains the number of elements specified by <paramref name="count" /> and that ends at <paramref name="startIndex" /> , using the specified comparison options; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The character to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the backward search.
count The number of elements in the section to search.
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
LastIndexOf​(string source, string value)
Searches for the specified substring and returns the zero-based index of the last occurrence within the entire source string.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within <paramref name="source" /> ; otherwise, -1.
source The string to search.
value The string to locate within <paramref name="source" /> .
public int
LastIndexOf​(string source, string value, CompareOptions options)
Searches for the specified substring and returns the zero-based index of the last occurrence within the entire source string using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within <paramref name="source" /> , using the specified comparison options; otherwise, -1.
source The string to search.
value The string to locate within <paramref name="source" /> .
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
LastIndexOf​(string source, string value, int startIndex)
Searches for the specified substring and returns the zero-based index of the last occurrence within the section of the source string that extends from the beginning of the string to the specified index.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that extends from the beginning of <paramref name="source" /> to <paramref name="startIndex" /> ; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the backward search.
public int
LastIndexOf​(string source, string value, int startIndex, CompareOptions options)
Searches for the specified substring and returns the zero-based index of the last occurrence within the section of the source string that extends from the beginning of the string to the specified index using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that extends from the beginning of <paramref name="source" /> to <paramref name="startIndex" /> , using the specified comparison options; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the backward search.
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public int
LastIndexOf​(string source, string value, int startIndex, int count)
Searches for the specified substring and returns the zero-based index of the last occurrence within the section of the source string that contains the specified number of elements and ends at the specified index.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that contains the number of elements specified by <paramref name="count" /> and that ends at <paramref name="startIndex" /> ; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the backward search.
count The number of elements in the section to search.
public int
LastIndexOf​(string source, string value, int startIndex, int count, CompareOptions options)
Searches for the specified substring and returns the zero-based index of the last occurrence within the section of the source string that contains the specified number of elements and ends at the specified index using the specified <see cref="T:System.Globalization.CompareOptions" /> value.
Returns The zero-based index of the last occurrence of <paramref name="value" /> , if found, within the section of <paramref name="source" /> that contains the number of elements specified by <paramref name="count" /> and that ends at <paramref name="startIndex" /> , using the specified comparison options; otherwise, -1. Returns <paramref name="startIndex" /> if <paramref name="value" /> is an ignorable character.
source The string to search.
value The string to locate within <paramref name="source" /> .
startIndex The zero-based starting index of the backward search.
count The number of elements in the section to search.
options A value that defines how <paramref name="source" /> and <paramref name="value" /> should be compared. <paramref name="options" /> is either the enumeration value <see cref="F:System.Globalization.CompareOptions.Ordinal" /> , or a bitwise combination of one or more of the following values: <see cref="F:System.Globalization.CompareOptions.IgnoreCase" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreSymbols" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreNonSpace" /> , <see cref="F:System.Globalization.CompareOptions.IgnoreWidth" /> , and <see cref="F:System.Globalization.CompareOptions.IgnoreKanaType" /> .
public string
ToString​()
Returns a string that represents the current <see cref="T:System.Globalization.CompareInfo" /> object.
Returns A string that represents the current <see cref="T:System.Globalization.CompareInfo" /> object.
protected void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .