[c#]代码库
/// <summary>
/// 将整数转为大写的中文数字
/// </summary>
/// <param name="ni_intInput"></param>
/// <returns></returns>
public static string ToCNUpperCase(int ni_intInput)
{
string tstrRet = "";
int tintInput;
int tintRemainder, tintDigitPosIndex = 0;
int tintLoopX = 0;
string[] tastrNumCNChar = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
string[] tastrDigitPosCNChar = new string[] { "", "十", "佰", "仟", "万", "亿" };
tintInput = ni_intInput;
tintLoopX = 0;
while (tintInput / 10 > 0 || tintInput > 0)
{
tintRemainder = (tintInput % 10);
if (tintLoopX == 5)//十万
tintDigitPosIndex = 1;
else if (tintLoopX == 8)//亿
tintDigitPosIndex = 5;
else if (tintLoopX == 9)//十亿
tintDigitPosIndex = 1;
//end if
if (tintRemainder > 0)
tstrRet
= tastrNumCNChar[tintRemainder] + tastrDigitPosCNChar[tintDigitPosIndex] + tstrRet;
else
tstrRet
= tastrNumCNChar[tintRemainder] + tstrRet; ;
//end if
tintDigitPosIndex += 1;
tintLoopX += 1;
tintInput /= 10;
}//end while
tstrRet = System.Text.RegularExpressions.Regex.Replace(tstrRet, "零零*零*", "零");
return tstrRet;
}//end
/// <summary>
/// 将整数转为小写的中文数字
/// </summary>
/// <param name="ni_intInput"></param>
/// <returns></returns>
public static string ToCNLowerCase(this int ni_intInput)
{
string tstrRet = "";
int tintInput;
int tintRemainder, tintDigitPosIndex = 0;
int tintLoopX = 0;
string[] tastrNumCNChar = new string[] { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
string[] tastrDigitPosCNChar = new string[] { "", "十", "百", "千", "万", "亿" };
tintInput = ni_intInput;
tintLoopX = 0;
while (tintInput / 10 > 0 || tintInput > 0)
{
tintRemainder = (tintInput % 10);
if (tintLoopX == 5)//十万
tintDigitPosIndex = 1;
else if (tintLoopX == 8)//亿
tintDigitPosIndex = 5;
else if (tintLoopX == 9)//十亿
tintDigitPosIndex = 1;
//end if
if (tintRemainder > 0)
tstrRet
= tastrNumCNChar[tintRemainder] + tastrDigitPosCNChar[tintDigitPosIndex] + tstrRet;
else
tstrRet
= tastrNumCNChar[tintRemainder] + tstrRet; ;
//end if
tintDigitPosIndex += 1;
tintLoopX += 1;
tintInput /= 10;
}//end while
tstrRet = System.Text.RegularExpressions.Regex.Replace(tstrRet, "零零*零*", "零");
return tstrRet;
}//end