日期:2014-05-17  浏览次数:20923 次

c#实现的阿拉伯数字转大写汉字金额
初学c# 请多指教

废话没有 直接上代码

//将阿拉伯数字转成大写中文
        public static string num2String(double num)
        {
            if (num >= 1000000000)
            {
                Console.WriteLine("num is too large");
                return "";
            }
            string result = "";
            string front = "";//整数部分
            string back = "";//小数部分
            string[] num_strs = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };//大写数字数组
            string[] num_dw = { "", "拾", "佰", "仟", "万", "拾万", "佰万", "仟万", "亿" };//大写数字单位数组
            string[] money_dw = { "分", "角", "圆" };//人民币单位数组
            string str_num = num.ToString();
            string[] strs = str_num.Split('.');
            if (num < 0)//负数的话
            {
                result += "负";
                str_num = str_num.Replace("-", "");
            }

            int num_f = 0;//整数部分
            int num_back = 0;//小数部分

            if (strs.Length == 2)
            {
                front = strs[0];
                back = strs[1];

                num_f = Convert.ToInt32(front);
                num_back = Convert.ToInt32(back);


            }
            else
            {
                front = num.ToString();
                num_f = Convert.ToInt32(front);
            }

            for (int i = 8; i >= 0; i--)//从八个0 就是亿开始
            {
                string cs = "1";//除数
                for (int j = 1; j <= i; j++)//除数补零
 &