/// <Summary>
/// This class converts Arabic numerals to uppercase Chinese
/// This class does not identify illegal numbers. Please determine in advance whether the numbers are valid
/// </Summary>
Public class ChineseNum
{
// Convert lowercase to uppercase
Public static string GetChineseNum (string p_num)
{
ChineseNum cn = new ChineseNum ();
Return cn. NumToChn (p_num );
}
// Convert the lower-case amount to the upper-case amount
Public static string GetUpperMoney (double p_Money)
{
ChineseNum cn = new ChineseNum ();
Return cn. GetMoneyChinese (p_Money );
}
// Convert numbers
Private char CharToNum (char x)
{
String stringChnNames = "0 August 5, 1234 ";
String stringNumNames = "0123456789 ";
Return stringChnNames [stringNumNames. IndexOf (x)];
}
// Convert an integer smaller
Private string WanStrToInt (string x)
{
String [] stringArrayLevelNames = new string [4] {"", "Ten", "Hundred", "Thousand "};
String ret = "";
Int I;
For (I = x. Length-1; I> = 0; I --)
If (x [I] = 0)
{
Ret = CharToNum (x [I]) + ret;
}
Else
{
Ret = CharToNum (x [I]) + stringArrayLevelNames [x. Length-1-I] + ret;
}
While (I = ret. IndexOf ("0 "))! =-1)
{
Ret = ret. Remove (I, 1 );
}
If (ret [ret. Length-1] = 0 & ret. Length> 1)
{
Ret = ret. Remove (ret. Length-1, 1 );
}
If (ret. Length> = 2 & ret. Substring (0, 2) = "10 ")
{
Ret = ret. Remove (0, 1 );
}
Return ret;
}
// Convert the integer
Private string StrToInt (string x)
{
Int len = x. Length;
String ret, temp;
If (len <= 4)
{
Ret = WanStrToInt (x );
}
Else if (len <= 8)
{
Ret = WanStrToInt (x. Substring (0, len-4) + "Ten Thousand ";
Temp = WanStrToInt (x. Substring (len-4, 4 ));
If (temp. IndexOf ("thousands") =-1 & temp! = "")
Ret + = "zero" + temp;
Else
Ret + = temp;
}
Else
{
Ret = WanStrToInt (x. Substring (0, len-8) + "";
Temp = WanStrToInt (x. Substring (len-8, 4 ));
If (temp. IndexOf ("thousands") =-1 & temp! = "")
{
Ret + = "zero" + temp;
}
Else
{
& Nbs