Skip to content

Commit 9ebca0d

Browse files
authored
use index from end expressions (#1431)
1 parent 6ff7d81 commit 9ebca0d

6 files changed

+6
-6
lines changed

src/Humanizer/Localisation/NumberToWords/AfrikaansNumberToWordsConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ string Convert(int number, bool isOrdinal)
106106
}
107107
else if (isOrdinal)
108108
{
109-
parts[parts.Count - 1] += "ste";
109+
parts[^1] += "ste";
110110
}
111111

112112
var toWords = string.Join(" ", parts);

src/Humanizer/Localisation/NumberToWords/ArmenianNumberToWordsConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ string ConvertImpl(long number, bool isOrdinal)
135135
}
136136
else if (isOrdinal)
137137
{
138-
parts[parts.Count - 1] += "երորդ";
138+
parts[^1] += "երորդ";
139139
}
140140

141141
var toWords = string.Join(" ", parts);

src/Humanizer/Localisation/NumberToWords/AzerbaijaniNumberToWordsConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public override string ConvertToOrdinal(int number)
9595
}
9696
}
9797

98-
if (word[word.Length - 1] == 't')
98+
if (word[^1] == 't')
9999
{
100100
word = word.Substring(0, word.Length - 1) + 'd';
101101
}

src/Humanizer/Localisation/NumberToWords/BulgarianNumberToWordsConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static string Convert(long input, GrammaticalGender gender, bool isOrdinal, bool
130130
}
131131

132132
if (isOrdinal && !string.IsNullOrWhiteSpace(lastOrdinalSubstitution))
133-
parts[parts.Count - 1] = lastOrdinalSubstitution;
133+
parts[^1] = lastOrdinalSubstitution;
134134

135135
return string.Join(" ", parts);
136136
}

src/Humanizer/Localisation/NumberToWords/CentralKurdishNumberToWordsConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public override string Convert(long number)
6464
public override string ConvertToOrdinal(int number)
6565
{
6666
var word = Convert(number);
67-
return $"{word}{(IsVowel(word[word.Length - 1]) ? "یەم" : "ەم")}";
67+
return $"{word}{(IsVowel(word[^1]) ? "یەم" : "ەم")}";
6868
}
6969

7070
static bool IsVowel(char c) =>

src/Humanizer/Localisation/NumberToWords/EnglishNumberToWordsConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ string Convert(long number, bool isOrdinal, bool addAnd = true)
110110
}
111111
else if (isOrdinal)
112112
{
113-
parts[parts.Count - 1] += "th";
113+
parts[^1] += "th";
114114
}
115115

116116
var toWords = string.Join(" ", parts);

0 commit comments

Comments
 (0)