日期:2014-05-18 浏览次数:20867 次
public string ConvertToChinese(string stringNumber) { string[] Price = { "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾", "佰", "仟" }; string[] PriceDot = { "角", "分", "厘" }; string[] Number = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" }; string MoneyPrice = stringNumber.ToString(); string MoneyPriceDot = string.Empty; if (stringNumber.IndexOf(".") > 1) { MoneyPrice = stringNumber.Split('.')[0]; MoneyPriceDot = stringNumber.Split('.')[1]; } string part1 = string.Empty; string part2 = string.Empty; for (int i = 0; i < MoneyPrice.Length; i++) { int numberIndex = Convert.ToInt32(MoneyPrice[i].ToString()); part1 += Number[numberIndex]; part1 += Price[MoneyPrice.Length - i - 1]; } if (MoneyPriceDot.Length > 0) { if (Convert.ToInt32(MoneyPriceDot) > 0) { for (int i = 0; i < MoneyPriceDot.Length; i++) { int numberIndex = Convert.ToInt32(MoneyPriceDot[i].ToString()); part2 += Number[numberIndex]; part2 += PriceDot[i]; } } } part1 = part1.Replace("零仟", "零"); part1 = part1.Replace("零佰", "零"); part1 = part1.Replace("零拾", "零"); part1 = part1.Replace("零元", "元"); part1 = part1.Replace("零零零万", ""); part1 = part1.Replace("零零零", "零"); part1 = part1.Replace("零零", "零"); part1 = part1.Replace("零万", "万"); part1 = part1.Replace("零亿", "亿"); part2 = part2.Replace("零角", "零"); part2 = part2.Replace("零分", "零"); part2 = part2.Replace("零厘", ""); part2 = part2.Replace("零零", "零"); return part1 + part2; }
------解决方案--------------------
网上很多的啊。。。
找个查不多的 。。
根据自己的实际情况修改下 。。
想在网上找一个适合自己的开发需求的 确实不多。。。。LZ要动动手啊。。