diff --git a/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs index b8e2193a3..47e71e729 100644 --- a/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/NorwegianBokmalNumberToWordsConverter.cs @@ -127,7 +127,7 @@ string Convert(int number, bool isOrdinal, GrammaticalGender gender) } else if (isOrdinal) { - parts[parts.Count - 1] += (number == 0 ? "" : "en") + (millionOrMore ? "te" : "de"); + parts[^1] += (number == 0 ? "" : "en") + (millionOrMore ? "te" : "de"); } var toWords = string.Concat(parts).Trim(); diff --git a/src/Humanizer/Localisation/NumberToWords/TamilNumberToWordsConverter.cs b/src/Humanizer/Localisation/NumberToWords/TamilNumberToWordsConverter.cs index f2e9e6da9..20c853b3f 100644 --- a/src/Humanizer/Localisation/NumberToWords/TamilNumberToWordsConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/TamilNumberToWordsConverter.cs @@ -78,7 +78,7 @@ string ConvertImpl(long number, bool isOrdinal) if (number > 0) parts.Add(GetTensValue(number, isOrdinal)); else if (isOrdinal) - parts[parts.Count - 1] += "வது"; + parts[^1] += "வது"; var toWords = string.Join(" ", parts); diff --git a/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs index 553913d3d..44e3cd78d 100644 --- a/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/TurkishNumberToWordConverter.cs @@ -120,7 +120,7 @@ public override string ConvertToOrdinal(int number) } } - if (word[word.Length - 1] == 't') + if (word[^1] == 't') { word = word.Substring(0, word.Length - 1) + 'd'; } diff --git a/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs index 1a1a070cd..50af6f60f 100644 --- a/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/UzbekCyrlNumberToWordConverter.cs @@ -85,7 +85,7 @@ public override string ConvertToOrdinal(int number) return string.Empty; } - var lastChar = word[word.Length - 1]; + var lastChar = word[^1]; if (lastChar is 'и' or 'а') { i = 1; diff --git a/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs b/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs index 6df6dbdcb..6805102db 100644 --- a/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs +++ b/src/Humanizer/Localisation/NumberToWords/UzbekLatnNumberToWordConverter.cs @@ -85,7 +85,7 @@ public override string ConvertToOrdinal(int number) return string.Empty; } - var lastChar = word[word.Length - 1]; + var lastChar = word[^1]; if (lastChar is 'i' or 'a') { i = 1; diff --git a/src/Humanizer/MetricNumeralExtensions.cs b/src/Humanizer/MetricNumeralExtensions.cs index c9542294c..a0ffbf1b0 100644 --- a/src/Humanizer/MetricNumeralExtensions.cs +++ b/src/Humanizer/MetricNumeralExtensions.cs @@ -98,7 +98,7 @@ static MetricNumeralExtensions() public static double FromMetric(this string input) { input = CleanRepresentation(input); - return BuildNumber(input, input[input.Length - 1]); + return BuildNumber(input, input[^1]); } ///