Return to Snippet

Revision: 32856
at November 8, 2010 21:50 by duncanmcdougall


Updated Code
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];
}

Revision: 32855
at November 8, 2010 21:47 by duncanmcdougall


Updated Code
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];
  }
}

Revision: 32854
at October 3, 2010 07:37 by duncanmcdougall


Updated Code
public static string[] SuffixLookup = { "th","st","nd","rd","th","th","th","th","th","th" };

public static string AppendOrdinalSuffix(int number)
{
  if (day % 100 >= 11 && day % 100 <= 13)
  {
    return day + "th"; return day + SuffixLookup[day % 10];
  }
}

Revision: 32853
at October 3, 2010 07:36 by duncanmcdougall


Updated Code
public static string[] SuffixLookup = { "th","st","nd","rd","th","th","th","th","th","th" };

public static string AppendOrdinalSuffix(int day)
{
  if (day % 100 >= 11 && day % 100 <= 13)
  {
    return day + "th"; return day + SuffixLookup[day % 10];
  }
}

Revision: 32852
at October 3, 2010 07:36 by duncanmcdougall


Initial Code
public static string[] SuffixLookup = { "th","st","nd","rd","th","th","th","th","th","th" };  public static string AppendOrdinalSuffix(int day)
{
  if (day % 100 >= 11 && day % 100 <= 13)
  {
    return day + "th"; return day + SuffixLookup[day % 10];
  }
}

Initial URL

                                

Initial Description

                                

Initial Title
Get Ordinal Suffix of a Number

Initial Tags

                                

Initial Language
C#