Click here to Skip to main content
12,453,873 members (73,564 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

4.1K views
1 bookmarked
Posted

Ordinal suffixes in English for the nth degree

, 14 Jun 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
What aboutpublic static string NUMthOF(UInt32 v){ return v.ToString() + // Append the ordinal suffix for the unit digit // unless the ten digit is a one (force 'th') "thstndrdthththththth".Substring(2 * (int)(v / 10 % 10 != 1 ? v % 10 : 0), 2);}?Now all...

What about

public static string NUMthOF(UInt32 v)
{
    return v.ToString() + 
        // Append the ordinal suffix for the unit digit
        // unless the ten digit is a one (force 'th')
        "thstndrdthththththth".Substring(2 * (int)(v / 10 % 10 != 1 ? v % 10 : 0), 2);
}

?

Now all the crypticism is concentrated in a single expression Smile | :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

YDaoust
CEO VISION fOr VISION
Belgium Belgium
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralThanks Pin
YDaoust14-Jun-11 1:43
memberYDaoust14-Jun-11 1:43 
GeneralExcellent. And the crypticism gets balanced very well by the... Pin
Luc Pattyn14-Jun-11 1:20
mvpLuc Pattyn14-Jun-11 1:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 14 Jun 2011
Article Copyright 2011 by YDaoust
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid