#region 阿拉伯数字换算中文
/// <summary>
/// 数字转文字(最多2位数)
/// </summary>
/// <param name="numberStr"></param>
/// <returns></returns>
public static string NumberToChinese(int num)
{
string numberStr = num.ToString();
char[] c = numberStr.ToCharArray();
string returnValue = "";
for (int i = 0; i < c.Length; i++)
{
int index = numberStr.IndexOf(c[i]);
returnValue += OneBitNumberToChinese(c[i].ToString());
if (c.Length == 2 && i == 0)
{//十
if (c[i] == '1')
{
returnValue = "十";
}
else
{
returnValue += "十";
}
}
}
returnValue = string.IsNullOrEmpty(returnValue) ? "零" : returnValue;
return returnValue;
}
//数字1-9转换为中文数字
public static string OneBitNumberToChinese(string num)
{
string numStr = "123456789";
string chineseStr = "一二三四五六七八九";
string result = "";
int numIndex = numStr.IndexOf(num);
if (numIndex > -1)
{
result = chineseStr.Substring(numIndex, 1);
}
return result;
}
#endregion