csharp Get Day Suffix

string GetDaySuffix(int day)
{
    switch (day)
    {
        case 1:
        case 21:
        case 31:
            return "st";
        case 2:
        case 22:
            return "nd";
        case 3:
        case 23:
            return "rd";
        default:
            return "th";
    }
}
Determines the suffix to be applied to a day, e.g. GetDaySuffix(1) becomes 1st.

Updated: Tuesday 14th February 2012, 06:32pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.