感谢Asp.Net技术前瞻--张明Blog
namespace BaseSystemFramework { using System; public class Capitalization { public Capitalization() { } //金额数字(小写)转换成文字(大写) private static string[] shuzi={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"}; private static string[] danwei={"分","角","元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"}; /**//// <summary> /// 金额小写转换成大写 /// </summary> /// <param name="payment"></param> /// <returns></returns> public static string MoneyConvert(double payment) { string money; int ipayment, itemp, num, length, danweinum; string spayment, stemp; bool yuan, wan, yi, zero; yi = false; wan = false; yuan = false; zero = false; money = ""; ipayment = (int)Math.Floor(payment*100+0.5); //转换成分并四舍五入 if( ipayment > 0 ) { spayment = ipayment.ToString(); //转换成字符串 length = spayment.Length; if( length > 0 ) { money = ""; num = length - 1; danweinum = 0; while( num >= 0 ) { stemp = spayment.Substring( num, 1 ); itemp = int.Parse( stemp ); if( itemp > 0 ) { if( money.Length > 0 ) { stemp = shuzi[itemp] + danwei[danweinum]; if( danweinum == 10 ) yi = true; if( danweinum == 6 ) wan = true; if( danweinum == 2 ) yuan = true; if( danweinum > 10 ) if( !yi ) { stemp = stemp + "亿"; yi = true; } if( danweinum > 6 ) if( !wan ) { stemp = stemp + "万"; wan = true; } if( danweinum > 2 ) if( !yuan ) { stemp = stemp + "元"; yuan = true; } money = stemp + money; } else { if( danweinum > 0 ) { stemp = shuzi[itemp] + danwei[danweinum]; if( danweinum == 10 ) yi = true; if( danweinum == 6 ) wan = true; if( danweinum == 2 ) yuan = true; if( danweinum > 10 ) if( !yi ) { stemp = stemp + "亿"; yi = true; } if( danweinum > 6 ) if( !wan ) { stemp = stemp + "万"; wan = true; } if( danweinum > 2 ) if( !yuan ) { stemp = stemp + "元"; yuan = true; } money = stemp + "整"; } else money = shuzi[itemp] + danwei[danweinum]; } zero = false; } else { if( money.Length > 0 ) if( !zero ) { money = shuzi[itemp] + money; } zero = true; } num--; danweinum++; } } } return money; } /**//// <summary> /// 金额小写转换成大写 /// </summary> /// <param name="payment"></param> /// <returns></returns> public static string MoneyConvert( string payment ) { if( payment.Length != 0) return MoneyConvert( Convert.ToDouble( payment ) ); else return MoneyConvert( Convert.ToDouble( "0" ) ); } } }