C # convert lowercase renminbi to uppercase

Source: Internet
Author: User

        /// <summary>         ///convert renminbi size amount/// </summary>         /// <param name= "num" >Amount</param>         /// <returns>return uppercase Form</returns>          Public Static stringCmycurd (decimalnum) {            stringSTR1 ="0 One and three Woolu Qi Ba Jiu";//0-9 The corresponding Chinese characters            stringSTR2 ="Thousand thousand hundred billion thousand to pick up thousand hundred yuan angle cent";//Chinese characters corresponding to digit digits            stringSTR3 ="";//value taken from the original NUM value            stringSTR4 ="";//the string form of a number            stringSTR5 ="";//RMB capitalization amount form            intI//Loop Variable            intJ//the value of num multiplied by the string length of 100            stringCH1 ="";//the Chinese reading method of numbers            stringCH2 ="";//the Chinese character reading method of digit digit            intNzero =0;//to calculate a continuous 0 value is a few            intTemp//value taken from the original NUM valueNum= Math.Round (Math.Abs (num),2);//Takes num absolute value and rounds it to 2 decimal placesSTR4 = ((Long) (NUM * -)). ToString ();//multiply num by 100 and convert to string formj = Str4. Length;//find the highest bit            if(J > the) {return "Overflow"; } STR2= str2. Substring ( the-j);//Remove the value of the str2 corresponding to the number of digits. such as: 200.55,j is 5, so str2= bai yuan Angle points//loop out the values that each bit needs to be converted             for(i =0; I < J; i++) {STR3= Str4. Substring (I,1);//Remove the value of a bit to be convertedtemp = Convert.ToInt32 (STR3);//Convert to Digital                if(I! = (J-3) && I! = (J-7) && I! = (J- One) && I! = (J- the))                {                    //When the number of digits is not the number of yuan, million, billion, trillion                    if(STR3 = ="0") {ch1=""; CH2=""; Nzero= Nzero +1; }                    Else                    {                        if(STR3! ="0"&& Nzero! =0) {ch1="0"+ str1. Substring (TEMP *1,1); CH2= str2. Substring (I,1); Nzero=0; }                        Else{ch1= str1. Substring (TEMP *1,1); CH2= str2. Substring (I,1); Nzero=0; }                    }                }                Else                {                    //This bit is a trillion, million, million, yuan and other key bits                    if(STR3! ="0"&& Nzero! =0) {ch1="0"+ str1. Substring (TEMP *1,1); CH2= str2. Substring (I,1); Nzero=0; }                    Else                    {                        if(STR3! ="0"&& Nzero = =0) {ch1= str1. Substring (TEMP *1,1); CH2= str2. Substring (I,1); Nzero=0; }                        Else                        {                            if(STR3 = ="0"&& Nzero >=3) {ch1=""; CH2=""; Nzero= Nzero +1; }                            Else                            {                                if(J >= One) {ch1=""; Nzero= Nzero +1; }                                Else{ch1=""; CH2= str2. Substring (I,1); Nzero= Nzero +1; }                            }                        }                    }                }                if(i = = (J- One) || i = = (J-3))                {                    //If the bit is an million-bit or meta-bit, you must write theCH2 = str2. Substring (I,1); } STR5= STR5 + Ch1 +CH2; if(i = = J-1&& STR3 = ="0")                {                    //The last one (minutes) is 0 o'clock, plus "whole"STR5 = STR5 +'Whole'; }            }            if(num = =0) {STR5="0 Yuan Whole"; }            returnSTR5; }        /**/        /// <summary>         ///an overload that converts the string first to a number in the call Cmycurd (decimal num)/// </summary>         /// <param name= "num" >amount entered by the user, string form not converted to decimal</param>         /// <returns></returns>          Public Static stringCmycurd (stringnumstr) {            Try            {                decimalnum =Convert.todecimal (NUMSTR); returncmycurd (num); }            Catch            {                return "non-digital form! "; }        }

C # convert lowercase renminbi to uppercase

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.