• C# 金额转换繁体大写


    方式一:拼接转换

     public string chang(string money)
            {
                //将小写金额转换成大写金额          
                double MyNumber = Convert.ToDouble (money );
                String[] MyScale = { "分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟", "兆", "拾", "佰", "仟" };
                String[] MyBase = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
                String M = "";
                bool isPoint = false;
                if (money.IndexOf(".") != -1)
                {
                    money = money.Remove(money.IndexOf("."), 1);
                    isPoint = true;
                }
                for (int i = money.Length; i > 0; i--)
                {
                    int MyData = Convert.ToInt16(money[money.Length - i].ToString ());
                    M += MyBase[MyData];
                    if (isPoint==true)
                    {
                        M += MyScale[i - 1];
                    }
                    else
                    {
                        M += MyScale[i + 1];
                    }
                }
                return M;
            }

    方式二:独立拆分打印

    调用:

     string data = "";
                        List<string> lisdata = new List<string>();
                        string strCapValue = String.Format("{0:f2}", Convert.ToDouble(txtTotalCharge.Text));
                        int intDotPos = strCapValue.IndexOf("."); //点的位置
                        bool isMinus = strCapValue.Substring(0, 1) == "-" ? true : false; //判断是否负数
                        int intBeginPos = isMinus ? 1 : 0; //数值的开始位置
                        string strCapInt = strCapValue.Substring(intBeginPos, isMinus ? intDotPos - 1 : intDotPos); //取出整数部分

                        //string strCapDec = strCapValue.Substring(intDotPos + 1); //取出小数部分
                        lisdata = chang(strCapInt);
                         int Index = 0;
                        for (int i = lisdata.Count - 1; i >= 0; i--)
                        {
                            int a = 50;
                            data = lisdata[i].ToString();
                            e.Graphics.DrawString(data, new Font("宋体", 10, FontStyle.Bold), Brushes.Black, 600 - (Index * a), 270);
                            Index++;
                        }

     public List<string> chang(string money)
            {
                List<string> list = new List<string>();

                 list.Add("¥");
                //将小写金额转换成大写金额            
                double MyNumber = Convert.ToDouble(money);
                String[] MyBase = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
                for (int i = money.Length; i > 0; i--)
                {
                    int MyData = Convert.ToInt16(money[money.Length - i].ToString());
                    list.Add(MyBase[MyData]);
                }
                return list;
            }

  • 相关阅读:
    React父组件调用子组件
    ES6数组操作
    ant design mobile入坑记
    vue
    图片上传七牛
    CSS
    CSS矩形、三角形等
    使用POST下载文件
    http https协议
    前端网络必备知识
  • 原文地址:https://www.cnblogs.com/quanxie/p/3026139.html
Copyright © 2020-2023  润新知