/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static string[] SuffixLookup = { "th","st","nd","rd","th","th","th","th","th","th" }; public static string AppendOrdinalSuffix(int number) { if (number % 100 >= 11 && number % 100 <= 13) { return number + "th"; } return number + SuffixLookup[number% 10]; }