zoukankan      html  css  js  c++  java
  • C#金额数字转换中文繁体

    /// <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;
    }

  • 相关阅读:
    hdu 6702 ^&^ 位运算
    hdu 6709 Fishing Master 贪心
    hdu 6704 K-th occurrence 二分 ST表 后缀数组 主席树
    hdu 1423 Greatest Common Increasing Subsequence 最长公共上升子序列 LCIS
    hdu 5909 Tree Cutting FWT
    luogu P1588 丢失的牛 宽搜
    luogu P1003 铺地毯
    luogu P1104 生日
    luogu P1094 纪念品分组
    luogu P1093 奖学金
  • 原文地址:https://www.cnblogs.com/zhian/p/8252136.html
Copyright © 2011-2022 走看看