KGy SOFT

StringSegmentComparer Class

KGy SOFT Core Libraries Help
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.
Inheritance Hierarchy

SystemObject
  KGySoft.CoreLibrariesStringSegmentComparer

Namespace:  KGySoft.CoreLibraries
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.4.0
Syntax

[SerializableAttribute]
public abstract class StringSegmentComparer : IEqualityComparer<StringSegment>, 
	IComparer<StringSegment>, IEqualityComparer<string>, IComparer<string>, 
	IEqualityComparer, IComparer

The StringSegmentComparer type exposes the following members.

Constructors

  NameDescription
Protected methodStringSegmentComparer
Initializes a new instance of the StringSegmentComparer class
Top
Properties

  NameDescription
Public propertyStatic memberCurrentCulture
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.
Public propertyStatic memberCurrentCultureIgnoreCase
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.
Public propertyStatic memberInvariantCulture
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.
Public propertyStatic memberInvariantCultureIgnoreCase
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.
Public propertyStatic memberOrdinal
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.
Public propertyStatic memberOrdinalIgnoreCase
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.
Top
Methods

  NameDescription
Public methodCompare(Object, Object)
When overridden in a derived class, compares two objects and returns an indication of their relative sort order.
Public methodCompare(ReadOnlySpanChar, ReadOnlySpanChar)
When overridden in a derived class, compares two ReadOnlySpan<char> instances and returns an indication of their relative sort order.
Public methodCompare(String, String)
When overridden in a derived class, compares two string instances and returns an indication of their relative sort order.
Public methodCompare(StringSegment, StringSegment)
When overridden in a derived class, compares two StringSegment instances and returns an indication of their relative sort order.
Public methodStatic memberCreate
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. See the Remarks section for details.
Public methodEquals(Object, Object)
When overridden in a derived class, indicates whether two objects are equal.
Public methodEquals(ReadOnlySpanChar, ReadOnlySpanChar)
When overridden in a derived class, indicates whether two ReadOnlySpan<char> instances are equal.
Public methodEquals(String, String)
When overridden in a derived class, indicates whether two string instances are equal.
Public methodEquals(StringSegment, StringSegment)
When overridden in a derived class, indicates whether two StringSegment instances are equal.
Public methodStatic memberFromComparison
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.
Public methodGetHashCode(Object)
When overridden in a derived class, gets the hash code for the specified object.
Public methodGetHashCode(ReadOnlySpanChar)
When overridden in a derived class, gets the hash code for the specified ReadOnlySpan<char>.
Public methodGetHashCode(String)
When overridden in a derived class, gets the hash code for the specified string.
Public methodGetHashCode(StringSegment)
When overridden in a derived class, gets the hash code for the specified StringSegment.
Top
Extension Methods

  NameDescription
Public Extension MethodConvert(Type, CultureInfo)Overloaded.
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.)
Public Extension MethodCode exampleConvertTTarget(CultureInfo)Overloaded.
Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions.)
Public Extension MethodIn (Defined by ObjectExtensions.)
Public Extension MethodTryConvert(Type, Object)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvert(Type, CultureInfo, Object)Overloaded.
Tries to convert an Object specified in the obj parameter to the desired targetType.
(Defined by ObjectExtensions.)
Public Extension MethodTryConvertTTarget(TTarget)Overloaded.
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.)
Public Extension MethodTryConvertTTarget(CultureInfo, TTarget)Overloaded.
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.)
Top
Remarks

Note Note
See Also

Reference