Class StringIncludingTerminatorComparer
An implementation of
Inheritance
System.Object
StringIncludingTerminatorComparer
Namespace: MoreStructures.Utilities
Assembly: MoreStructures.dll
Syntax
public class StringIncludingTerminatorComparer : IComparer<string>
Properties
| Improve this Doc View SourceTerminator
The character acting as terminator, and which has to be considered smaller than any other char.
Declaration
public char Terminator { get; }
Property Value
Type | Description |
---|---|
System.Char |
Methods
| Improve this Doc View SourceBuild(Char)
Builds a StringIncludingTerminatorComparer with the provided terminator
.
Caches instances.
Declaration
public static StringIncludingTerminatorComparer Build(char terminator)
Parameters
Type | Name | Description |
---|---|---|
System.Char | terminator |
Returns
Type | Description |
---|---|
StringIncludingTerminatorComparer | An instance of StringIncludingTerminatorComparer, new or previously created and cached. |
Compare(String, String)
Declaration
public int Compare(string x, string y)
Parameters
Type | Name | Description |
---|---|---|
System.String | x | |
System.String | y |
Returns
Type | Description |
---|---|
System.Int32 |
Remarks
Special rules applied by StringIncludingTerminatorComparer:
- If either string is null or empty, the standard System.String.Compare(System.String,System.String) is used.
- If one string starts with the terminator, and the other doesn't, the one which does is smaller.
- If none of the cases above applies, System.String.Compare(System.String,System.String) is used on the
substring starting from index 1 of each of the strings
x
andy
.