首页 技术 正文
技术 2022年11月18日
0 收藏 492 点赞 3,087 浏览 1558 个字

/// <summary>
/// 数字转换中文繁体金钱
/// </summary>
/// <param name=”Digital”></param>
/// <returns></returns>
public static string ConvertChineseMoney(decimal Digital)
{
string strChineseMoney = string.Empty;
//将小写金额转换成大写金额
String[] ArrMyScale = { “圆”, “拾”, “佰”, “仟”, “万”, “拾”, “佰”, “仟”, “亿”, “拾”, “佰”, “仟”, “兆”, “拾”, “佰”, “仟” };
string[] ArrDecimalScale = { “角”, “分”, “厘”, “毫” };

Dictionary<string, string> dicmybase = new Dictionary<string, string>();
dicmybase.Add(“0”, “零”);
dicmybase.Add(“1”, “壹”);
dicmybase.Add(“2”, “贰”);
dicmybase.Add(“3”, “叁”);
dicmybase.Add(“4”, “肆”);
dicmybase.Add(“5”, “伍”);
dicmybase.Add(“6”, “陆”);
dicmybase.Add(“7”, “柒”);
dicmybase.Add(“8”, “捌”);
dicmybase.Add(“9”, “玖”);

String[] MyBase = { “零”, “壹”, “贰”, “叁”, “肆”, “伍”, “陆”, “柒”, “捌”, “玖” };

string moneyDigital = Digital.ToString();
string strmoneyint = Digital.ToString();
string strmoneyDecimal = string.Empty;
if (moneyDigital.IndexOf(“.”) != -1)
{
//moneyDigital = moneyDigital.Remove(moneyDigital.IndexOf(“.”), 1);
//isPoint = true;
strmoneyint = Digital.ToString().Substring(0, moneyDigital.IndexOf(“.”));
strmoneyDecimal = Digital.ToString().Substring(moneyDigital.IndexOf(“.”)+1);
strmoneyDecimal = strmoneyDecimal.TrimEnd(‘0’);
}
//整数部分
if (!string.IsNullOrWhiteSpace(strmoneyint))
{
int intlength = strmoneyint.Length;
for (int count = 0; count <= intlength – 1; count++)
{
strChineseMoney += dicmybase[strmoneyint.Substring(count, 1)] + ArrMyScale[intlength – count-1];
}
}
//判断小数部分
if (!string.IsNullOrWhiteSpace(strmoneyDecimal))
{
int Decimallength = strmoneyDecimal.Length;
for (int count = 0; count <= Decimallength – 1; count++)
{
strChineseMoney += dicmybase[strmoneyDecimal.Substring(count, 1)] + ArrDecimalScale[count];
}
}
return strChineseMoney;
}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,412
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,185
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905