Need a quick .Net function to add ordinals to numbers?
Don’t know what an ordinal is (I didn’t).
Its numbers written like 1st 2nd 3rd etc.
Anyway here’s the function -
private string placelabel(int num)
{
switch (num % 100)
{
case 11:
case 12:
case 13:
return num.ToString() + "th";
}
switch (num % 10)
{
case 1:
return num.ToString() + "st";
case 2:
return num.ToString() + "nd";
case 3:
return num.ToString() + "rd";
default:
return num.ToString() + "th";
}
}