Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
/// <summary>
       /// this is for get postfix for numbers
       /// </summary>
       /// <param name="number"></param>
       /// <returns></returns>
       public static string ToOrdinal(int number)
       {
           switch (number % 100)
           {
               case 11:
               case 12:
               case 13:
                   return number + "th";
           }

           switch (number % 10)
           {
               case 1:
                   return number + "st";
               case 2:
                   return number + "nd";
               case 3:
                   return number + "rd";
               default:
                   return number + "th";
           }
       }
Posted
Comments
Richard MacCutchan 5-Jun-14 7:26am    
Your question says one thing but your code says something else. Perhaps you could edit your question and explain your problem in better detail.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900