Class CharComparer
Represents a character comparison operation that uses specific case and culture-based or ordinal comparison rules.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public abstract class CharComparer : IEqualityComparer<char>, IComparer<char>
Constructors
View SourceCharComparer()
Initializes a new instance of comparer.
Declaration
protected CharComparer()
Methods
View SourceCompare(char, char)
Compares two characters and returns an indication of their relative sort order.
Declaration
public abstract int Compare(char x, char y)
Parameters
| Type | Name | Description |
|---|---|---|
| char | x | The first character to compare. |
| char | y | The second character to compare. |
Returns
| Type | Description |
|---|---|
| int | A number indicating relative sort order of the characters. |
Compare(char, char, StringComparison)
Compares two characters and returns an indication of their relative sort order.
Declaration
public static int Compare(char x, char y, StringComparison comparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| char | x | The first character to compare. |
| char | y | The second character to compare. |
| StringComparison | comparisonType | The comparison type. |
Returns
| Type | Description |
|---|---|
| int | A number indicating relative sort order of the characters. |
Create(CultureInfo, CompareOptions)
Creates character comparer for the specified culture.
Declaration
public static CharComparer Create(CultureInfo culture, CompareOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | culture | A culture whose linguistic rules are used to perform a string comparison. |
| CompareOptions | options | Comparison options. |
Returns
| Type | Description |
|---|---|
| CharComparer | Culture-specific comparer. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
Equals(char, char)
Determines whether the two characters are equal.
Declaration
public abstract bool Equals(char x, char y)
Parameters
| Type | Name | Description |
|---|---|---|
| char | x | The first character to compare. |
| char | y | The second character to compare. |
Returns
| Type | Description |
|---|---|
| bool |
Equals(char, char, StringComparison)
Determines whether the two characters are equal.
Declaration
public static bool Equals(char x, char y, StringComparison comparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| char | x | The first character to compare. |
| char | y | The second character to compare. |
| StringComparison | comparisonType | The comparison type. |
Returns
| Type | Description |
|---|---|
| bool |
FromComparison(StringComparison)
Converts StringComparison to CharComparer.
Declaration
public static CharComparer FromComparison(StringComparison comparison)
Parameters
| Type | Name | Description |
|---|---|---|
| StringComparison | comparison | A character comparer instance to convert. |
Returns
| Type | Description |
|---|---|
| CharComparer | A comparer representing the specified comparison type. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
GetHashCode(char)
Gets the hash code for the specified character.
Declaration
public abstract int GetHashCode(char ch)
Parameters
| Type | Name | Description |
|---|---|---|
| char | ch | A character. |
Returns
| Type | Description |
|---|---|
| int | A hash code of the character. |
GetHashCode(char, StringComparison)
Gets the hash code for the specified character.
Declaration
public static int GetHashCode(char ch, StringComparison comparisonType)
Parameters
| Type | Name | Description |
|---|---|---|
| char | ch | A character. |
| StringComparison | comparisonType | The comparison type. |
Returns
| Type | Description |
|---|---|
| int | A hash code of the character. |