在.NET中有一个简单的方法来获得“st”,“nd”,“rd”和“th”数字结局 [英] Is there an easy way in .NET to get "st", "nd", "rd" and "th" endings for numbers?
本文介绍了在.NET中有一个简单的方法来获得“st”,“nd”,“rd”和“th”数字结局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1至1
2至2
3至3
4至4
11至11
101至101st
111至111th
此链接是编写自己的函数所涉及的基本原则的一个坏例子,但如果我缺少内置的容量,我更好奇。
解决方案
Scott Hanselman的答案是接受的答案,因为它回答了问题直接。
然而,有一个解决方案,请参阅。
解决方案
不,没有内置的ca .NET基类库中的pability。
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 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.
Solution
Scott Hanselman's answer is the accepted one because it answers the question directly.
For a solution however, see this great answer.
解决方案
No, there is no inbuilt capability in the .NET Base Class Library.
这篇关于在.NET中有一个简单的方法来获得“st”,“nd”,“rd”和“th”数字结局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文