From the course: C#: String Essential Training
Unlock the full course today
Join today to access over 24,000 courses taught by industry experts.
Challenge: Ordinal formatting - C# Tutorial
From the course: C#: String Essential Training
Challenge: Ordinal formatting
(upbeat music) - [Instructor] I want to pose a formatting challenge for you. The idea is we're going to have a code challenge to format a number as an ordinal string. Now, the issue is, is that in .NET, there is not a built-in way to format number values as ordinal strings, like this, with the number one, and then the "st" abbreviation, and then the number two, and the "nd" abbreviation. Now, note that this example I'm showing you here is specific to English ordinals. If you're working in a different culture, use whichever ordinal values make sense for your culture. Here's a review of what it's like for English numbers. I want you to create code that formats an inbound number with an ordinal suffix. So for the first number, and 21, and 31, and 41, and so on, you're going to use "st." For the second number, you use "nd," that's for second, 22nd, 32nd. Fourth through 10th have "th" as the ordinal suffix, and that's the…