StringSegmentComparer Class

Represents a string comparison operation that uses specific case and culture-based or ordinal comparison rules allowing comparing strings by string, StringSegment and ReadOnlySpan<char> instances.
See the static properties for more details.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0
C#
[SerializableAttribute]
public abstract class StringSegmentComparer : IEqualityComparer<StringSegment>, 
	IComparer<StringSegment>, IEqualityComparer<string>, IComparer<string>, 
	IEqualityComparer, IComparer
Inheritance
Object    StringSegmentComparer
Implements
IComparerStringSegment, IComparerString, IEqualityComparerStringSegment, IEqualityComparerString, IComparer, IEqualityComparer

Constructors

StringSegmentComparerInitializes a new instance of the StringSegmentComparer class

Properties

CurrentCulture Gets a StringSegmentComparer object that performs a case-sensitive string comparison using the word comparison rules of the current culture.
Depending on the targeted platform, the GetHashCode(StringSegment) method might allocate a new string. In .NET Core 3.0 and above none of the members of the returned StringSegmentComparer will allocate new strings.
CurrentCultureIgnoreCase Gets a StringSegmentComparer object that performs case-insensitive string comparisons using the word comparison rules of the current culture.
Depending on the targeted platform, the GetHashCode(StringSegment) method might allocate a new string. In .NET Core 3.0 and above none of the members of the returned StringSegmentComparer will allocate new strings.
InvariantCulture Gets a StringSegmentComparer object that performs a case-sensitive string comparison using the word comparison rules of the invariant culture.
Depending on the targeted platform, the GetHashCode(StringSegment) method might allocate a new string. In .NET Core 3.0 and above none of the members of the returned StringSegmentComparer will allocate new strings.
InvariantCultureIgnoreCase Gets a StringSegmentComparer object that performs a case-insensitive string comparison using the word comparison rules of the invariant culture.
Depending on the targeted platform, the GetHashCode(StringSegment) method might allocate a new string. In .NET Core 3.0 and above none of the members of the returned StringSegmentComparer will allocate new strings.
Ordinal Gets a StringSegmentComparer object that performs a case-sensitive ordinal string comparison.
The methods of the returned StringSegmentComparer instance can be called with string, StringSegment and ReadOnlySpan<char> parameter values, which will not allocate new strings on any platform.
OrdinalIgnoreCase Gets a StringSegmentComparer object that performs a case-insensitive ordinal string comparison.
The methods of the returned StringSegmentComparer instance can be called with string, StringSegment and ReadOnlySpan<char> parameter values, which will not allocate new strings on any platform.
OrdinalIgnoreCaseRandomized Gets a StringSegmentComparer object that performs a case-insensitive ordinal string comparison. The returned comparer is functionally equivalent with OrdinalIgnoreCase but it ensures that the hash code of a specific string is stable only within the same process and AppDomain.
OrdinalRandomized Gets a StringSegmentComparer object that performs a case-sensitive ordinal string comparison. The returned comparer is functionally equivalent with Ordinal but it ensures that the hash code of a specific string is stable only within the same process and AppDomain.

Methods

Compare(Object, Object) When overridden in a derived class, compares two objects and returns an indication of their relative sort order.
Compare(ReadOnlySpanChar, ReadOnlySpanChar) When overridden in a derived class, compares two ReadOnlySpan<char> instances and returns an indication of their relative sort order.
Compare(String, String) When overridden in a derived class, compares two string instances and returns an indication of their relative sort order.
Compare(StringSegment, StringSegment) When overridden in a derived class, compares two StringSegment instances and returns an indication of their relative sort order.
Create Creates a StringSegmentComparer object that compares strings according to the rules of a specified culture.
Please note that the returned StringSegmentComparer may allocate new strings in some cases when targeting older frameworks. See the Remarks section for details.
Equals(Object, Object) When overridden in a derived class, indicates whether two objects are equal.
Equals(ReadOnlySpanChar, ReadOnlySpanChar) When overridden in a derived class, indicates whether two ReadOnlySpan<char> instances are equal.
Equals(String, String) When overridden in a derived class, indicates whether two string instances are equal.
Equals(StringSegment, StringSegment) When overridden in a derived class, indicates whether two StringSegment instances are equal.
FromComparison Gets a StringSegmentComparer instance based on the specified comparison.
Please note that the returned StringSegmentComparer may allocate new strings in some cases. See the description of the properties for more details.
GetHashCode(Object) When overridden in a derived class, gets the hash code for the specified object.
GetHashCode(ReadOnlySpanChar) When overridden in a derived class, gets the hash code for the specified ReadOnlySpan<char>.
GetHashCode(String) When overridden in a derived class, gets the hash code for the specified string.
GetHashCode(StringSegment) When overridden in a derived class, gets the hash code for the specified StringSegment.

Extension Methods

Convert Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions)
ConvertTTarget Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions)
In Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)

See Also