c#将数字转换为货币格式
答案:2 悬赏:10
解决时间 2021-02-08 03:35
- 提问者网友:冰点阿弟
- 2021-02-07 08:13
c#将数字转换为货币格式
最佳答案
- 二级知识专家网友:茫然不知崩溃
- 2021-02-07 08:55
直接调chang()这个方法就行 string ht1 = chang(convert.todouble(234.45)); public static string chang(double digital) { //将小写金额转换成大写金额 string[] myscale = { "分", "角", "圆", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾", "佰", "仟" }; string[] mybase = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; string moneystr = ""; bool ispoint = false; string moneydigital = digital.tostring(); if (moneydigital.indexof(".") != -1) { moneydigital = moneydigital.remove(moneydigital.indexof("."), 1); ispoint = true; } for (int i = moneydigital.length; i > 0; i--) { int mydata = convert.toint16(moneydigital[moneydigital.length - i].tostring()); moneystr += mybase[mydata]; if (ispoint == true) { moneystr += myscale[i - 1]; } else { moneystr += myscale[i + 1]; } } while (moneystr.contains("零零")) moneystr = moneystr.replace("零零", "零"); moneystr = moneystr.replace("零亿", "亿"); moneystr = moneystr.replace("亿万", "亿"); moneystr = moneystr.replace("零万", "万"); moneystr = moneystr.replace("零仟", "零"); moneystr = moneystr.replace("零佰", "零"); moneystr = moneystr.replace("零拾", "零"); while (moneystr.contains("零零")) moneystr = moneystr.replace("零零", "零"); moneystr = moneystr.replace("零圆", "圆"); moneystr = moneystr.replace("零角", ""); moneystr = moneystr.replace("零分", ""); moneystr = moneystr + "整"; return moneystr; }
全部回答
- 1楼网友:气场征服一切
- 2021-02-07 10:26
int i = 60000;
string d=i.ToString("c");
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |