10万以内数字转换为中文小写

        private string convertnumber(int number)
        {
            string[] Ls_ShZ = { "〇", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
            string[] Ls_DW_Zh = { "十", "百", "千", "万" };


            string str = null;
            string str_number = number.ToString();
            string[] x = new string[str_number.Length];
            for (int i = 0; i < str_number.Length; i++)
            {
                x[i] = str_number.Substring(i, 1);
            }


            for (int i = 0; i < x.Length; i++)
            {
                str =str+ Ls_ShZ[Convert.ToInt32(x[i])];
            }


            switch (str.Length)
            {
                case 1:
                    {
                        str = str.Substring(0, 1);
                    }
                    break;
                case 2:
                    {
                        str = str.Substring(0, 1) + Ls_DW_Zh[0] + str.Substring(1, 1);
                    }
                    break;
                case 3:
                    {
                        str = str.Substring(0, 1) + Ls_DW_Zh[1] + str.Substring(1, 1) + Ls_DW_Zh[0] + str.Substring(2, 1);
                    }
                    break;
                case 4:
                    {
                        str = str.Substring(0, 1) + Ls_DW_Zh[2] + str.Substring(1, 1) + Ls_DW_Zh[1] + str.Substring(2, 1) + Ls_DW_Zh[0] + str.Substring(3, 1);
                    }
                    break;
                case 5:
                    {
                        str = str.Substring(0, 1) + Ls_DW_Zh[3] + str.Substring(1, 1) + Ls_DW_Zh[2] + str.Substring(2, 1) + Ls_DW_Zh[1] + str.Substring(3, 1) + Ls_DW_Zh[0] + str.Substring(4, 1);
                    }
                    break;
                default:
                    str = "";
                    break;
            }


            for (int i = 0; i < str.Length;i++ )
            {
                str = str.Replace("〇十", "〇");
                str = str.Replace("〇百", "〇");
                str = str.Replace("〇千", "〇");
                str = str.Replace("〇万", "〇");
                str = str.Replace("〇〇", "〇");
            }


            for (int i = 0; i < str.Length; i++)
            {
                if (str.Substring(str.Length - 1, 1) == "〇")
                {
                    str = str.Substring(0, str.Length - 1);
                }
            }


                return str;


            }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值