Here is another version of the Ordinalize() extension, short and sweet:
public static string Ordinalize(this int x)
{
var xString = x.ToString();
var xLength = xString.Length;
var xLastTwoCharacters = xString.Substring(Math.Max(0, xLength - 2));
return xString +
((x % 10 == 1 && xLastTwoCharacters != "11")
? "st"
: (x % 10 == 2 && xLastTwoCharacters != "12")
? "nd"
: (x % 10 == 3 && xLastTwoCharacters != "13")
? "rd"
: "th");
}
and then call that extension like this
myDate.Day.Ordinalize()
or
myAnyNumber.Ordinalize()