Call Method: Public stringConverttochinesenumber (stringOld ) {Chinese ch=NewChinese (); Longnum =Convert.toint64 (old); stringRe =ch.returnresult (num); if(Re. StartsWith ("One pick") ) {Re= Re. Substring (1, Re. Length-1); } return(re); }
Full CodeusingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespacepublic{classChinese { Public stringReturnresult (Longnum) { stringNumstr =Num. ToString (); if(Numstr.length >8& Numstr.length < -) { string[] Firstsplit =New string[2]; firstsplit[0] = numstr.substring (0, Numstr.length-8); firstsplit[1] = numstr.substring (Numstr.length-8,8); stringRESULT1 = getString (firstsplit[0]) +"Yi"; stringRESULT2 = getString (firstsplit[1]); returnRESULT1 +result2; } Else { returngetString (NUMSTR); } } Public stringGetString (stringstr) { if(str. Length >4) { string[] Secondsplit =New string[2]; secondsplit[0] = str. Substring (0Str. Length-4); secondsplit[1] = str. Substring (str. Length-4,4); stringRESULT1 = Getre (secondsplit[0]); stringRESULT2 = Getre (secondsplit[1]); if(!secondsplit[0]. Equals ("0000") ) {RESULT1+=" million"; } returnRESULT1 +result2; } Else { returngetre (str); } } int[] Value = { +, -,Ten }; Public stringGetre (stringDowith) { Char[] Number =Dowith.tochararray (); intLength =Number . Length; stringRe =""; for(inti =0; i < length; i++) { Switch(Number[i]) { Case '0': if(Re. EndsWith ("0") ) {Re+=""; } Else{re+="0"; } Break; Case '1': Re+=" One"; Break; Case '2': Re+="Ii."; Break; Case '3': Re+="three"; Break; Case '4': Re+="Restaurant"; Break; Case '5': Re+="Wu"; Break; Case '6': Re+="Lu"; Break; Case '7': Re+="Qi"; Break; Case '8': Re+="BA"; Break; Case '9': Re+="JIU"; Break; } intindex = (int) Math.pow (Ten, Length-i-1); if(Number[i]. ToString () = ="0") {Index= -1; } Switch(index) { Case +: Re+="Qian"; Break; Case -: Re+="Bai"; Break; Case Ten: Re+="Pick"; Break; } } if(Re. EndsWith ("0") ) {Re= Re. Substring (0, Re. Length-1); } returnre; } }}
Http://files.cnblogs.com/files/louby/1279894919.rar
C # Arabic numerals translated into Chinese