Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CompareTo()

static int System.MemoryExtensions.CompareTo ( this ReadOnlySpan< char > span,
ReadOnlySpan< char > other,
StringComparison comparisonType )
inlinestatic

Definition at line 1415 of file MemoryExtensions.cs.

1416 {
1417 string.CheckStringComparison(comparisonType);
1418 switch (comparisonType)
1419 {
1420 case StringComparison.CurrentCulture:
1421 case StringComparison.CurrentCultureIgnoreCase:
1422 return CultureInfo.CurrentCulture.CompareInfo.Compare(span, other, string.GetCaseCompareOfComparisonCulture(comparisonType));
1423 case StringComparison.InvariantCulture:
1424 case StringComparison.InvariantCultureIgnoreCase:
1425 return CompareInfo.Invariant.Compare(span, other, string.GetCaseCompareOfComparisonCulture(comparisonType));
1426 case StringComparison.Ordinal:
1427 if (span.Length == 0 || other.Length == 0)
1428 {
1429 return span.Length - other.Length;
1430 }
1431 return string.CompareOrdinal(span, other);
1432 default:
1433 return Ordinal.CompareStringIgnoreCase(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length);
1434 }
1435 }
static readonly CompareInfo Invariant
static CultureInfo CurrentCulture
static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char strB, int lengthB)
Definition Ordinal.cs:8

References System.Globalization.Ordinal.CompareStringIgnoreCase(), System.comparisonType, System.Globalization.CultureInfo.CurrentCulture, System.Globalization.CompareInfo.Invariant, and System.other.