[Serializable] |
Unlike most classes, CompareInfo provides the CompareInfo.GetCompareInfo method, instead of public constructors, to allow for late-bound access.
To create a CompareInfo for any culture, use the CultureInfo.CompareInfo property, or use the CompareInfo.GetCompareInfo method.
LCID | Read-only Gets the properly formed culture identifier for the current CompareInfo. |
Compare | Overloaded:Compare(string string1, string string2) Compares two strings using the default CompareOptions value. |
Compare | Overloaded:Compare(string string1, string string2, CompareOptions options) Compares two strings using the specified CompareOptions value. |
Compare | Overloaded:Compare(string string1, int offset1, string string2, int offset2) Compares the end section of a string with the end section of another string. |
Compare | Overloaded: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 CompareOptions value. |
Compare | Overloaded: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. |
Compare | Overloaded: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 CompareOptions value. |
Equals | Overridden: Determines whether the specified object is the same instance as the current CompareInfo. |
GetCompareInfo | Overloaded:GetCompareInfo(int culture) Initializes a new instance of the CompareInfo class that is associated with the culture having the specified identifier. |
GetCompareInfo | Overloaded:GetCompareInfo(string name) Initializes a new instance of the CompareInfo class that is associated with the culture having the specified name. |
GetCompareInfo | Overloaded:GetCompareInfo(int culture, Assembly assembly) Initializes a new instance of the CompareInfo class that is associated with the culture having the specified identifier and uses string comparison methods in the specified Assembly. |
GetCompareInfo | Overloaded:GetCompareInfo(string name, Assembly assembly) Initializes a new instance of the CompareInfo class that is associated with the culture having the specified name and uses string comparison methods in the specified Assembly. |
GetHashCode | Overridden: Serves as a hash function for the current CompareInfo for use in hashing algorithms and data structures, such as a hash table. |
GetSortKey | Overloaded:GetSortKey(string source) Gets the SortKey of the specified string. |
GetSortKey | Overloaded:GetSortKey(string source, CompareOptions options) Gets the SortKey of the specified string using the specified CompareOptions value. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
IndexOf | Overloaded: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. |
IndexOf | Overloaded: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. |
IndexOf | Overloaded: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 CompareOptions value. |
IndexOf | Overloaded: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. |
IndexOf | Overloaded: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 CompareOptions value. |
IndexOf | Overloaded: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. |
IndexOf | Overloaded: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 CompareOptions value. |
IndexOf | Overloaded: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. |
IndexOf | Overloaded: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 CompareOptions value. |
IndexOf | Overloaded: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. |
IndexOf | Overloaded: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 CompareOptions value. |
IndexOf | Overloaded: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 CompareOptions value. |
IsPrefix | Overloaded:IsPrefix(string source, string prefix) Determines whether the specified source string starts with the specified prefix. |
IsPrefix | Overloaded:IsPrefix(string source, string prefix, CompareOptions options) Determines whether the specified source string starts with the specified prefix using the specified CompareOptions value. |
IsSuffix | Overloaded:IsSuffix(string source, string suffix) Determines whether the specified source string ends with the specified suffix. |
IsSuffix | Overloaded:IsSuffix(string source, string suffix, CompareOptions options) Determines whether the specified source string ends with the specified suffix using the specified CompareOptions value. |
LastIndexOf | Overloaded: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. |
LastIndexOf | Overloaded: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. |
LastIndexOf | Overloaded: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 CompareOptions value. |
LastIndexOf | Overloaded: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. |
LastIndexOf | Overloaded: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 CompareOptions value. |
LastIndexOf | Overloaded: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. |
LastIndexOf | Overloaded: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 CompareOptions value. |
LastIndexOf | Overloaded: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. |
LastIndexOf | Overloaded: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 CompareOptions value. |
LastIndexOf | Overloaded: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. |
LastIndexOf | Overloaded: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 CompareOptions value. |
LastIndexOf | Overloaded: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 CompareOptions value. |
ToString | Overridden: Returns a string that represents the current CompareInfo. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public int LCID {get;}
|
string1
string2
Value | Condition |
---|---|
zero | The two strings are equal. |
less than zero | is less than . |
greater than zero | is greater than . |
public virtual int Compare(string string1, string string2, Compare( |
string1
string2
options
Value | Condition |
---|---|
zero | The two strings are equal. |
less than zero | is less than . |
greater than zero | is greater than . |
Exception Type | Condition |
---|---|
ArgumentException | options is not a valid CompareOptions value. |
string1
offset1
string2
offset2
Value | Condition |
---|---|
zero | The two strings are equal. |
less than zero | The specified section of is less than the specified section of . |
greater than zero | The specified section of is greater than the specified section of . |
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | offset1 or offset2 is less than zero. -or- offset1 is greater than or equal to the number of characters in string1. -or- offset2 is greater than or equal to the number of characters in string2. |
public virtual int Compare(string string1, int offset1, string string2, int offset2, Compare( |
string1
offset1
string2
offset2
options
Value | Condition |
---|---|
zero | The two strings are equal. |
less than zero | The specified section of is less than the specified section of . |
greater than zero | The specified section of is greater than the specified section of . |
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | offset1 or offset2 is less than zero. -or- offset1 is greater than or equal to the number of characters in string1. -or- offset2 is greater than or equal to the number of characters in string2. |
ArgumentException | options is not a valid CompareOptions value. |
public virtual int Compare( |
string1
offset1
length1
string2
offset2
length2
Value | Condition |
---|---|
zero | The two strings are equal. |
less than zero | The specified section of is less than the specified section of . |
greater than zero | The specified section of is greater than the specified section of . |
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | offset1 or length1 or offset2 or length2 is less than zero. -or- offset1 is greater than or equal to the number of characters in string1. -or- offset2 is greater than or equal to the number of characters in string2. -or- length1 is greater than the number of characters from offset1 to the end of string1. -or- length2 is greater than the number of characters from offset2 to the end of string2. |
public virtual int Compare(string string1, int offset1, int length1, string string2, int offset2, int length2, Compare( |
string1
offset1
length1
string2
offset2
length2
options
Value | Condition |
---|---|
zero | The two strings are equal. |
less than zero | The specified section of is less than the specified section of . |
greater than zero | The specified section of is greater than the specified section of . |
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | offset1 or length1 or offset2 or length2 is less than zero. -or- offset1 is greater than or equal to the number of characters in string1. -or- offset2 is greater than or equal to the number of characters in string2. -or- length1 is greater than the number of characters from offset1 to the end of string1. -or- length2 is greater than the number of characters from offset2 to the end of string2. |
ArgumentException | options is not a valid CompareOptions value. |
value
~CompareInfo(); |
public static CompareInfo GetCompareInfo( |
culture
public static CompareInfo GetCompareInfo( |
name
Exception Type | Condition |
---|---|
ArgumentNullException | name is null. |
ArgumentException | name is an invalid culture name. |
public static CompareInfo GetCompareInfo( |
culture
assembly
Exception Type | Condition |
---|---|
ArgumentNullException | assembly is null. |
ArgumentException | assembly is of an invalid type. |
public static CompareInfo GetCompareInfo( |
name
assembly
Exception Type | Condition |
---|---|
ArgumentNullException | name is null. -or- assembly is null. |
ArgumentException | name is an invalid culture name. -or- assembly is of an invalid type. |
public override int GetHashCode(); |
This method generates the same hash code for two objects that are equal according to the CompareInfo.Equals method.
source
public virtual SortKey GetSortKey( |
source
options
Exception Type | Condition |
---|---|
ArgumentException | options is not a valid CompareOptions value. |
public Type GetType(); |
source
value
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
This overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
source
value
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
This overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
public virtual int IndexOf( |
source
value
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
source
value
startIndex
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. |
This overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
public virtual int IndexOf( |
source
value
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
source
value
startIndex
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. |
This overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
public virtual int IndexOf( |
source
value
startIndex
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
source
value
startIndex
count
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. -or- count is less than zero. -or- startIndex and count do not specify a valid section in source. |
This overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
public virtual int IndexOf( |
source
value
startIndex
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
source
value
startIndex
count
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. -or- count is less than zero. -or- startIndex and count do not specify a valid section in source. |
This overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
public virtual int IndexOf( |
source
value
startIndex
count
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. -or- count is less than zero. -or- startIndex and count do not specify a valid section in source. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
public virtual int IndexOf( |
source
value
startIndex
count
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. -or- count is less than zero. -or- startIndex and count do not specify a valid section in source. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
source
prefix
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- prefix is null. |
public virtual bool IsPrefix( |
source
prefix
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- prefix is null. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
source
suffix
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- suffix is null. |
public virtual bool IsSuffix( |
source
suffix
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- suffix is null. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
source
value
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
This overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
source
value
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
This overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
public virtual int LastIndexOf( |
source
value
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
source
value
startIndex
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. |
This overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
public virtual int LastIndexOf( |
source
value
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
source
value
startIndex
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. |
This overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
public virtual int LastIndexOf( |
source
value
startIndex
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
source
value
startIndex
count
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. -or- count is less than zero. -or- startIndex and count do not specify a valid section in source. |
This overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
public virtual int LastIndexOf( |
source
value
startIndex
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
source
value
startIndex
count
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. -or- count is less than zero. -or- startIndex and count do not specify a valid section in source. |
This overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
public virtual int LastIndexOf( |
source
value
startIndex
count
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. -or- count is less than zero. -or- startIndex and count do not specify a valid section in source. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, if the char is a Unicode value representing a precomposed character, such as the ligature
public virtual int LastIndexOf( |
source
value
startIndex
count
options
Exception Type | Condition |
---|---|
ArgumentNullException | source is null. -or- value is null. |
ArgumentOutOfRangeException | startIndex is outside the range of valid indexes for source. -or- count is less than zero. -or- startIndex and count do not specify a valid section in source. |
ArgumentException | options is not a valid CompareOptions value. |
The CompareOptions.StringSort value is not valid for this method.
If options does not include the CompareOptions.Ordinal value, this overload performs a culture-sensitive search; that is, a Unicode value representing a precomposed character, such as the ligature
protected object MemberwiseClone(); |
public override string ToString(); |