• 小写转 大写


    //转换大写
    private string Change(double Digital)
    {
    //将小写金额转换成大写金额
    String[] MyScale = { "分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾", "佰", "仟" };
    String[] MyBase = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
    String moneyStr = "";
    bool isPoint = false;
    string moneyDigital = Digital.ToString();
    int leng = 0;//金额长度
    string str = string.Empty;//小数点后字符长度
    if (moneyDigital.IndexOf(".") != -1)
    {
    str = moneyDigital.Substring(moneyDigital.IndexOf(".") + 1);
    moneyDigital = moneyDigital.Remove(moneyDigital.IndexOf("."), 1);
    isPoint = true;

    if (str.Length == 1)
    {
    leng = moneyDigital.Length + 1;
    }
    else
    {
    leng = moneyDigital.Length;
    }
    }
    else
    {
    leng = moneyDigital.Length;
    }
    for (int i = leng; i > 0; i--)
    {
    if (str.Length == 1 && i == 1)
    {
    break;
    }
    int MyData = Convert.ToInt16(moneyDigital[leng - 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("零分", "");
    if (moneyStr.Contains("角") || moneyStr.Contains("分"))//有角或者分的情况
    {
    if (moneyStr.Contains("拾") || moneyStr.Contains("佰") || moneyStr.Contains("仟") || moneyStr.Contains("万") || moneyStr.Contains("亿") || moneyStr.Contains("兆"))//整数位有数据的情况
    {
    moneyStr = moneyStr.Replace("零圆", "圆");
    }
    else//整数位没有数据的情况
    {
    moneyStr = moneyStr.Replace("零圆", "");
    }
    }
    else//没有角分,零圆替换成圆
    {
    moneyStr = moneyStr.Replace("零圆", "圆");
    }
    moneyStr = moneyStr + "整";
    return moneyStr;
    }

  • 相关阅读:
    ovs流表机制(四)用vxlan实现多个节点的vm通信(二)
    expect
    在Scrapy中使用Selenium
    Python网络编程
    Scrapy持久化存储
    Scrapy基础
    Selenium实例
    XML和XPATH
    猫眼电影爬取
    Request模块
  • 原文地址:https://www.cnblogs.com/yangpeng-jingjing/p/8781007.html
Copyright © 2020-2023  润新知