money capital

public string NumGetStr(double Num)
{
string[] DX_SZ = { "zero", "one", "two", "three", "four", "wu", "lu", "qi", "8", "jiu", "pick up" };//uppercase number
string[] DX_DW = { "yuan", "pick up", "hundred", "thousand", "ten thousand", "pick up", "hundred", "thousand" , "billion", "picks", "hundreds", "thousands", "ten thousand" };
string[] DX_XSDS = { "angle", "minutes" };//larger decimal units
if (Num == 0) return DX_SZ[0];

Boolean IsXS_bool = false;//Is it decimal

string NumStr;//The whole number string
string NumStr_Zs;//Integer part
string NumSr_Xs = "";//Decimal part
string NumStr_R = "";//Returned string


NumStr = Num.ToString();
NumStr_Zs = NumStr;
if (NumStr_Zs.Contains("."))
{
NumStr = Math.Round(Num, 2).ToString();
NumStr_Zs = NumStr.Substring(0, NumStr.IndexOf("."));
NumSr_Xs = NumStr.Substring((NumStr.IndexOf(".") + 1), (NumStr.Length - NumStr.IndexOf(".") - 1));
IsXS_bool = true;
}

int k = 0;
Boolean IsZeor = false;//The case of continuous 0 in the middle of the integer
for (int i = 0; i < NumStr_Zs.Length; i++) //Integer
{
int j = int.Parse(NumStr_Zs.Substring(i, 1));
if (j != 0)
{
NumStr_R += DX_SZ[j] + DX_DW[NumStr_Zs.Length - i - 1];
IsZeor = false; //no consecutive 0s
}
else if (j == 0)
{
k++;
if (!IsZeor && !(NumStr_Zs.Length == i + 1)) //Equal to 0 is not the last digit, take a continuous 0
{
//There is a problem
if (NumStr_Zs.Length - i - 1 >= 4 && NumStr_Zs.Length - i - 1 <= 6)
NumStr_R += DX_DW[4] + "zero";
else
if (NumStr_Zs.Length - i - 1 > 7)
NumStr_R += DX_DW[8] + "zero";
else
NumStr_R += "zero";

IsZeor = true;
}

if (NumStr_Zs.Length == i + 1)// is equal to 0 and the last digit becomes XX integer
NumStr_R += DX_DW[NumStr_Zs.Length - i - 1];
}

}
if (NumStr_Zs.Length > 2 && k == NumStr_Zs.Length - 1)
NumStr_R = NumStr_R.Remove(NumStr_R.IndexOf('zero'), 1); //For example, 1000, in the case of 10000 yuan, go to 0

if (!IsXS_bool) return NumStr_R + "integer"; //if there is no decimal, return
else
{
for (int i = 0; i < NumSr_Xs.Length; i++)
{
int j = int.Parse(NumSr_Xs.Substring(i, 1));
NumStr_R += DX_SZ[j] + DX_XSDS[NumSr_Xs.Length - i - 1];
}
}

return NumStr_R;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325778475&siteId=291194637