人名币转大写
2017-04-27 18:21 糯米粥 阅读(385) 评论(0) 编辑 收藏 举报 public static string get(string num)
{
//129
string chNum = "零壹贰叁肆伍陆柒捌玖";//定义好大写的数字
string zheng = "元拾佰仟万拾佰仟亿拾佰仟万";//定义好数位,从小到大排
string xiaoshu = "角分";//把整数和小数分开处理
string result = string.Empty;
if (num.Contains("."))
{
string[] temp = num.Split('.');
int index = temp[0].Length - 1;
for (int i = 0; i < temp[0].Length; i++)
{
result += chNum[Convert.ToInt32(temp[0][i].ToString())];
result += zheng[index];
index--;
}
for (int i = 0; i < temp[1].Length; i++)
{
//89
result += chNum[Convert.ToInt32(temp[1][i].ToString())];
result += xiaoshu[i];
}
}
else
{
int index = num.Length - 1;
for (int i = 0; i < num.Length; i++)
{
result += chNum[Convert.ToInt32(num[i].ToString())];
result += zheng[index];
index--;
}
}
return result;
}
调用 string result = get("129.98");