Last active
November 16, 2022 08:44
-
-
Save angelyordanov/8204fd7cf5110a7e3a28020ed86f8a13 to your computer and use it in GitHub Desktop.
числителни редни имена
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OrdinalNumbers | |
{ | |
public static string GetOrdinal(int number) | |
=> $"{number}{GetOrdinalSuffix(number)}"; | |
public static string GetOrdinalSuffix(int number) | |
=> number < 0 | |
? "" | |
: (number % 100) switch | |
{ | |
0 => "", | |
11 or 12 or 17 or 18 => "ти", | |
int n => | |
(n % 10) switch | |
{ | |
1 => "ви", | |
2 => "ри", | |
7 or 8 => "ми", | |
_ => "ти", | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment