Represents a string comparison operation that uses specific case and culture-based or ordinal comparison rules.
More...
|
int | Compare (object x, object y) |
| When overridden in a derived class, compares two objects and returns an indication of their relative sort order. More...
|
|
new bool | Equals (object x, object y) |
| When overridden in a derived class, indicates whether two objects are equal. More...
|
|
int | GetHashCode (object obj) |
| When overridden in a derived class, gets the hash code for the specified object. More...
|
|
abstract int | Compare (string x, string y) |
| When overridden in a derived class, compares two strings and returns an indication of their relative sort order. More...
|
|
abstract bool | Equals (string x, string y) |
| When overridden in a derived class, indicates whether two strings are equal. More...
|
|
abstract int | GetHashCode (string obj) |
| When overridden in a derived class, gets the hash code for the specified string. More...
|
|
int | Compare (object x, object y) |
| Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other. More...
|
|
bool | Equals (T x, T y) |
| Determines whether the specified objects are equal. More...
|
|
int | GetHashCode (T obj) |
| Returns a hash code for the specified object. More...
|
|
|
static StringComparer | InvariantCulture => _invariantCulture |
| Gets a T:System.StringComparer object that performs a case-sensitive string comparison using the word comparison rules of the invariant culture. More...
|
|
static StringComparer | InvariantCultureIgnoreCase => _invariantCultureIgnoreCase |
| Gets a T:System.StringComparer object that performs a case-insensitive string comparison using the word comparison rules of the invariant culture. More...
|
|
Represents a string comparison operation that uses specific case and culture-based or ordinal comparison rules.
Definition at line 12 of file StringComparer.cs.
◆ StringComparer()
System.StringComparer.StringComparer |
( |
| ) |
|
|
protected |
Initializes a new instance of the T:System.StringComparer class.
Definition at line 216 of file StringComparer.cs.
◆ Compare() [1/2]
int System.StringComparer.Compare |
( |
object |
x, |
|
|
object |
y |
|
) |
| |
When overridden in a derived class, compares two objects and returns an indication of their relative sort order.
- Parameters
-
x | An object to compare to y . |
y | An object to compare to x . |
- Returns
- A signed integer that indicates the relative values of x and y , as shown in the following table.ValueMeaningLess than zero x precedes y in the sort order. -or- x is
null
and y is not null
.Zero x is equal to y .-or- x and y are both null
. Greater than zero x follows y in the sort order.-or- y is null
and x is not null
.
- Exceptions
-
T:System.ArgumentException | Neither x nor y is a T:System.String object, and neither x nor y implements the T:System.IComparable interface. |
Implements System.Collections.IComparer.
Definition at line 106 of file StringComparer.cs.
◆ Compare() [2/2]
abstract int System.StringComparer.Compare |
( |
string |
x, |
|
|
string |
y |
|
) |
| |
|
pure virtual |
When overridden in a derived class, compares two strings and returns an indication of their relative sort order.
- Parameters
-
x | A string to compare to y . |
y | A string to compare to x . |
- Returns
- A signed integer that indicates the relative values of x and y , as shown in the following table.ValueMeaningLess than zero x precedes y in the sort order.-or- x is
null
and y is not null
.Zero x is equal to y .-or- x and y are both null
. Greater than zero x follows y in the sort order.-or- y is null
and x is not null
.
◆ Create()
Creates a T:System.StringComparer object that compares strings according to the rules of a specified culture.
- Parameters
-
culture | A culture whose linguistic rules are used to perform a string comparison. |
ignoreCase | true to specify that comparison operations be case-insensitive; false to specify that comparison operations be case-sensitive. |
- Returns
- A new T:System.StringComparer object that performs string comparisons according to the comparison rules used by the culture parameter and the case rule specified by the ignoreCase parameter.
- Exceptions
-
T:System.ArgumentNullException | culture is null . |
Definition at line 86 of file StringComparer.cs.
◆ Equals() [1/2]
new bool System.StringComparer.Equals |
( |
object |
x, |
|
|
object |
y |
|
) |
| |
When overridden in a derived class, indicates whether two objects are equal.
- Parameters
-
x | An object to compare to y . |
y | An object to compare to x . |
- Returns
true
if x and y refer to the same object, or x and y are both the same type of object and those objects are equal, or both x and y are null
; otherwise, false
.
Implements System.Collections.IEqualityComparer.
Definition at line 142 of file StringComparer.cs.
◆ Equals() [2/2]
abstract bool System.StringComparer.Equals |
( |
string |
x, |
|
|
string |
y |
|
) |
| |
|
pure virtual |
When overridden in a derived class, indicates whether two strings are equal.
- Parameters
-
x | A string to compare to y . |
y | A string to compare to x . |
- Returns
true
if x and y refer to the same object, or x and y are equal, or x and y are null
; otherwise, false
.
◆ GetHashCode() [1/2]
int System.StringComparer.GetHashCode |
( |
object |
obj | ) |
|
When overridden in a derived class, gets the hash code for the specified object.
- Parameters
-
- Returns
- A 32-bit signed hash code calculated from the value of the obj parameter.
- Exceptions
-
T:System.ArgumentException | Not enough memory is available to allocate the buffer that is required to compute the hash code. |
T:System.ArgumentNullException | obj is null . |
Implements System.Collections.IEqualityComparer.
Definition at line 170 of file StringComparer.cs.
◆ GetHashCode() [2/2]
abstract int System.StringComparer.GetHashCode |
( |
string |
obj | ) |
|
|
pure virtual |
When overridden in a derived class, gets the hash code for the specified string.
- Parameters
-
- Returns
- A 32-bit signed hash code calculated from the value of the obj parameter.
- Exceptions
-
T:System.ArgumentException | Not enough memory is available to allocate the buffer that is required to compute the hash code. |
T:System.ArgumentNullException | obj is null . |
◆ InvariantCulture
StringComparer System.StringComparer.InvariantCulture => _invariantCulture |
|
static |
Gets a T:System.StringComparer object that performs a case-sensitive string comparison using the word comparison rules of the invariant culture.
- Returns
- A new T:System.StringComparer object.
Definition at line 24 of file StringComparer.cs.
◆ InvariantCultureIgnoreCase
StringComparer System.StringComparer.InvariantCultureIgnoreCase => _invariantCultureIgnoreCase |
|
static |
Gets a T:System.StringComparer object that performs a case-insensitive string comparison using the word comparison rules of the invariant culture.
- Returns
- A new T:System.StringComparer object.
Definition at line 28 of file StringComparer.cs.
◆ CurrentCulture
Gets a T:System.StringComparer object that performs a case-sensitive string comparison using the word comparison rules of the current culture.
- Returns
- A new T:System.StringComparer object.
Definition at line 34 of file StringComparer.cs.
◆ CurrentCultureIgnoreCase
Gets a T:System.StringComparer object that performs case-insensitive string comparisons using the word comparison rules of the current culture.
- Returns
- A new T:System.StringComparer object.
Definition at line 46 of file StringComparer.cs.
◆ Ordinal
Gets a T:System.StringComparer object that performs a case-sensitive ordinal string comparison.
- Returns
- A T:System.StringComparer object.
Definition at line 58 of file StringComparer.cs.
◆ OrdinalIgnoreCase
Gets a T:System.StringComparer object that performs a case-insensitive ordinal string comparison.
- Returns
- A T:System.StringComparer object.
Definition at line 70 of file StringComparer.cs.
The documentation for this class was generated from the following file: