转载自网络....
1 public static string CmycurD(double num)
2 {
3 string str1 = "零壹贰叁肆伍陆柒捌玖"; //0-9所对应的汉字
4 string str2 = "万仟佰拾亿仟佰拾万仟佰拾元角分"; //数字位所对应的汉字
5 string str3 = ""; //从原num值中取出的值
6 string str4 = ""; //数字的字符串形式
7 string str5 = ""; //人民币大写金额形式
8 int j; //num的值乘以100的字符串长度
9 string ch1 = ""; //数字的汉语读法
10 string ch2 = ""; //数字位的汉字读法
11 int nzero = 0; //用来计算连续的零值是几个
12 int temp; //从原num值中取出的值
13
14 num = Math.Round(Math.Abs(num), 2); //将num取绝对值并四舍五入取2位小数
15 str4 = (num * 100).ToString(); //将num乘100并转换成字符串形式
16 j = str4.Length; //找出最高位
17 if (j > 15)
18 {
19 return "溢出";
20 }
21 str2 = str2.Substring(15 - j); //取出对应位数的str2的值。如:200.55,j为5所以str2=佰拾元角分
22
23 //循环取出每一位需要转换的值
24 for (int i = 0; i < j; i++)
25 {
26 str3 = str4.Substring(i, 1); //取出需转换的某一位的值
27 temp = Convert.ToInt32(str3); //转换为数字
28 if (i != (j - 3) && i != (j - 7) && i != (j - 11) && i != (j - 15))
29 {
30 //当所取位数不为元、万、亿、万亿上的数字时
31 if (str3 == "0")
32 {
33 ch1 = "";
34 ch2 = "";
35 nzero = nzero + 1;
36 }
37 else
38 {
39 if (str3 != "0" && nzero != 0)
40 {
41 ch1 = "零" + str1.Substring(temp * 1, 1);
42 ch2 = str2.Substring(i, 1);
43 nzero = 0;
44 }
45 else
46 {
47 ch1 = str1.Substring(temp * 1, 1);
48 ch2 = str2.Substring(i, 1);
49 nzero = 0;
50 }
51 }
52 }
53 else
54 {
55 //该位是万亿,亿,万,元位等关键位
56 if (str3 != "0" && nzero != 0)
57 {
58 ch1 = "零" + str1.Substring(temp * 1, 1);
59 ch2 = str2.Substring(i, 1);
60 nzero = 0;
61 }
62 else
63 {
64 if (str3 != "0" && nzero == 0)
65 {
66 ch1 = str1.Substring(temp * 1, 1);
67 ch2 = str2.Substring(i, 1);
68 nzero = 0;
69 }
70 else
71 {
72 if (str3 == "0" && nzero >= 3)
73 {
74 ch1 = "";
75 ch2 = "";
76 nzero = nzero + 1;
77 }
78 else
79 {
87 ch1 = "";
88 ch2 = str2.Substring(i, 1);
89 nzero = nzero + 1;
91 }
92 }
93 }
94 }
95 if (i == (j - 11) || i == (j - 3))
96 {
97 //如果该位是亿位或元位,则必须写上
98 ch2 = str2.Substring(i, 1);
99 }
100 str5 = str5 + ch1 + ch2;
101 if (i == j - 1 && str3 == "0")
102 {
103 //最后一位(分)为0时,加上“整”
104 str5 = str5 + '整';
105 }
106 }
107 if (num == 0)
108 {
109 str5 = "零元整";
110 }
111 return str5;
112 }
2 {
3 string str1 = "零壹贰叁肆伍陆柒捌玖"; //0-9所对应的汉字
4 string str2 = "万仟佰拾亿仟佰拾万仟佰拾元角分"; //数字位所对应的汉字
5 string str3 = ""; //从原num值中取出的值
6 string str4 = ""; //数字的字符串形式
7 string str5 = ""; //人民币大写金额形式
8 int j; //num的值乘以100的字符串长度
9 string ch1 = ""; //数字的汉语读法
10 string ch2 = ""; //数字位的汉字读法
11 int nzero = 0; //用来计算连续的零值是几个
12 int temp; //从原num值中取出的值
13
14 num = Math.Round(Math.Abs(num), 2); //将num取绝对值并四舍五入取2位小数
15 str4 = (num * 100).ToString(); //将num乘100并转换成字符串形式
16 j = str4.Length; //找出最高位
17 if (j > 15)
18 {
19 return "溢出";
20 }
21 str2 = str2.Substring(15 - j); //取出对应位数的str2的值。如:200.55,j为5所以str2=佰拾元角分
22
23 //循环取出每一位需要转换的值
24 for (int i = 0; i < j; i++)
25 {
26 str3 = str4.Substring(i, 1); //取出需转换的某一位的值
27 temp = Convert.ToInt32(str3); //转换为数字
28 if (i != (j - 3) && i != (j - 7) && i != (j - 11) && i != (j - 15))
29 {
30 //当所取位数不为元、万、亿、万亿上的数字时
31 if (str3 == "0")
32 {
33 ch1 = "";
34 ch2 = "";
35 nzero = nzero + 1;
36 }
37 else
38 {
39 if (str3 != "0" && nzero != 0)
40 {
41 ch1 = "零" + str1.Substring(temp * 1, 1);
42 ch2 = str2.Substring(i, 1);
43 nzero = 0;
44 }
45 else
46 {
47 ch1 = str1.Substring(temp * 1, 1);
48 ch2 = str2.Substring(i, 1);
49 nzero = 0;
50 }
51 }
52 }
53 else
54 {
55 //该位是万亿,亿,万,元位等关键位
56 if (str3 != "0" && nzero != 0)
57 {
58 ch1 = "零" + str1.Substring(temp * 1, 1);
59 ch2 = str2.Substring(i, 1);
60 nzero = 0;
61 }
62 else
63 {
64 if (str3 != "0" && nzero == 0)
65 {
66 ch1 = str1.Substring(temp * 1, 1);
67 ch2 = str2.Substring(i, 1);
68 nzero = 0;
69 }
70 else
71 {
72 if (str3 == "0" && nzero >= 3)
73 {
74 ch1 = "";
75 ch2 = "";
76 nzero = nzero + 1;
77 }
78 else
79 {
87 ch1 = "";
88 ch2 = str2.Substring(i, 1);
89 nzero = nzero + 1;
91 }
92 }
93 }
94 }
95 if (i == (j - 11) || i == (j - 3))
96 {
97 //如果该位是亿位或元位,则必须写上
98 ch2 = str2.Substring(i, 1);
99 }
100 str5 = str5 + ch1 + ch2;
101 if (i == j - 1 && str3 == "0")
102 {
103 //最后一位(分)为0时,加上“整”
104 str5 = str5 + '整';
105 }
106 }
107 if (num == 0)
108 {
109 str5 = "零元整";
110 }
111 return str5;
112 }