Public static string CmycurD (decimal num)
{
String str1 = ""; // Chinese characters corresponding to 0-9
String str2 = "tens of thousands of Chinese characters, hundreds of millions of Chinese characters, and tens of thousands of Chinese characters"; // Chinese characters corresponding to digits
String str3 = ""; // value retrieved from the original num Value
String str4 = ""; // string format of a number
String str5 = ""; // the capital amount of RMB
Int I; // cyclic variable
Int j; // multiply the value of num by the string length of 100
String delimiter = ""; // Chinese reading of numbers
String ch2 = ""; // Chinese character reading of digits
Int nzero = 0; // number of consecutive zero values used for calculation
Int temp; // value retrieved from the original num Value
Num = Math. Round (Math. Abs (num), 2); // returns the absolute value of num and rounding it to 2 decimal places.
Str4 = (long) (num * 100). ToString (); // multiply num by 100 and convert it into a string
J = str4.Length; // locate the highest bit
If (j> 15) {return "overflow ";}
Str2 = str2.Substring (15-j); // retrieve the str2 value of the corresponding number of digits. For example: 200.55, j is 5, so str2 = hour
// Cyclically retrieve the value to be converted for each bit
For (I = 0; I <j; I ++)
{
Str3 = str4.Substring (I, 1); // retrieves the value of a certain bit to be converted.
Temp = Convert. ToInt32 (str3); // Convert to a number
If (I! = (J-3) & I! = (J-7) & I! = (J-11) & I! = (J-15 ))
{
// When the number of retrieved digits is not RMB, or trillions of digits
If (str3 = "0 ")
{
Operator = "";
Ch2 = "";
Nzero = nzero + 1;
}
Else
{
If (str3! = "0" & nzero! = 0)
{
Bytes = "zero" + str1.Substring (temp * 1, 1 );
Ch2 = str2.Substring (I, 1 );
Nzero = 0;
}
Else
{
Dependencies = str1.Substring (temp * 1, 1 );
Ch2 = str2.Substring (I, 1 );
Nzero = 0;
}
}
}
Else
{
// This digit is a key digit of trillions, hundreds of millions, tens of thousands, and Yuan.
If (str3! = "0" & nzero! = 0)
{
Bytes = "zero" + str1.Substring (temp * 1, 1 );
Ch2 = str2.Substring (I, 1 );
Nzero = 0;
}
Else
{
If (str3! = "0" & nzero = 0)
{
Dependencies = str1.Substring (temp * 1, 1 );
Ch2 = str2.Substring (I, 1 );
Nzero = 0;
}
Else
{
If (str3 = "0" & nzero> = 3)
{
Operator = "";
Ch2 = "";
Nzero = nzero + 1;
}
Else
{
If (j> = 11)
{
Operator = "";
Nzero = nzero + 1;
}
Else
{
Operator = "";
Ch2 = str2.Substring (I, 1 );
Nzero = nzero + 1;
}
}
}
}
}
If (I = (j-11) | I = (j-3 ))
{
// If this digit is a hundred million or a metadigit, it must be written
Ch2 = str2.Substring (I, 1 );
}
Str5 = str5 + separator + ch2;
If (I = j-1 & str3 = "0 ")
{
// When the last digit (minute) is 0, add an integer"
Str5 = str5 + 'Integral ';
}
}
If (num = 0)
{
Str5 = "Zero RMB ";
}
Return str5;
}
Public static string CmycurD (string numstr)
{
Try
{
Decimal num = Convert. ToDecimal (numstr );
Return CmycurD (num );
}
Catch
{
Return "not digit form! ";
}
}