有没有在.NET中一个简单的方法来获得" ST","第二"," RD"和"日"结尾的数字?
问题描述:
我想知道是否有方法或格式字符串我缺少的.NET转换如下:
I am wondering if there is a method or format string I'm missing in .NET to convert the following:
1 to 1st
2 to 2nd
3 to 3rd
4 to 4th
11 to 11th
101 to 101st
111 to 111th
This链接有参与编写你自己的函数的基本原则了一个坏榜样,但我更好奇,如果有一个内置的能力,我失踪了。
This link has a bad example of the basic principle involved in writing your own function, but I am more curious if there is an inbuilt capacity I'm missing.
解决方案
在Scott Hanselman的答案是公认的,因为它直接回答了这个问题。
Scott Hanselman's answer is the accepted one because it answers the question directly.
有关的解决方案然而,看到this伟大的答案。
For a solution however, see this great answer.
答
没有,还有就是.NET基础类库中没有内置的功能。
No, there is no inbuilt capability in the .NET Base Class Library.