This has already been covered but I'm unsure how to link to it. Here is the code snippit:
public static string Ordinal(this int number)
{
var ones = number % 10;
var tens = Math.Floor (number / 10f) % 10;
if (tens == 1)
{
return number + "th";
}
switch (ones)
{
case 1: return number + "st";
case 2: return number + "nd";
case 3: return number + "rd";
default: return number + "th";
}
}
FYI: This is as an extension method. If your .NET version is less than 3.5 just remove the this keyword
[EDIT]: Thanks for pointing that it was incorrect, that's what you get for copy / pasting code :)