是否存在可用于将整数转换为语言表示形式的库或类/函数?
输入示例:
4,567,788`
输出示例:
四百万,五十六万七千七百七十八
如果您使用以下代码: 将数字转换为单词C#, 并且需要十进制数字,请按以下步骤操作:
public string DecimalToWords(decimal number) { if (number == 0) return "zero"; if (number < 0) return "minus " + DecimalToWords(Math.Abs(number)); string words = ""; int intPortion = (int)number; decimal fraction = (number - intPortion)*100; int decPortion = (int)fraction; words = NumericToWords(intPortion); if (decPortion > 0) { words += " and "; words += NumericToWords(decPortion); } return words; }