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

◆ EndsWith() [4/4]

bool System.String.EndsWith ( string value,
StringComparison comparisonType )
inline

Definition at line 453 of file String.cs.

454 {
455 if ((object)value == null)
456 {
457 throw new ArgumentNullException("value");
458 }
459 if ((object)this == value)
460 {
462 return true;
463 }
464 if (value.Length == 0)
465 {
467 return true;
468 }
469 switch (comparisonType)
470 {
471 case StringComparison.CurrentCulture:
472 case StringComparison.CurrentCultureIgnoreCase:
474 case StringComparison.InvariantCulture:
475 case StringComparison.InvariantCultureIgnoreCase:
477 case StringComparison.Ordinal:
478 {
479 int num = Length - value.Length;
480 if ((uint)num <= (uint)Length)
481 {
482 return this.AsSpan(num).SequenceEqual(value);
483 }
484 return false;
485 }
486 case StringComparison.OrdinalIgnoreCase:
487 if (Length >= value.Length)
488 {
489 return Ordinal.CompareStringIgnoreCase(ref Unsafe.Add(ref GetRawStringData(), Length - value.Length), value.Length, ref value.GetRawStringData(), value.Length) == 0;
490 }
491 return false;
492 default:
493 throw new ArgumentException(SR.NotSupported_StringComparison, "comparisonType");
494 }
495 }
static readonly CompareInfo Invariant
static CultureInfo CurrentCulture
static int CompareStringIgnoreCase(ref char strA, int lengthA, ref char strB, int lengthB)
Definition Ordinal.cs:8
ref char GetRawStringData()
Definition String.cs:1351
static void CheckStringComparison(StringComparison comparisonType)
Definition String.cs:882
static CompareOptions GetCaseCompareOfComparisonCulture(StringComparison comparisonType)
Definition String.cs:890

References System.String.CheckStringComparison(), System.Globalization.Ordinal.CompareStringIgnoreCase(), System.comparisonType, System.Globalization.CultureInfo.CurrentCulture, System.String.GetCaseCompareOfComparisonCulture(), System.String.GetRawStringData(), System.Globalization.CompareInfo.Invariant, System.String.Length, System.SR.NotSupported_StringComparison, and System.value.