Call the Convertmoney Convertmoneytowords (Decimal money) method to
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Text.RegularExpressions;usingsystem.web;namespacecommon{ Public classConvertmoney {Static string[] C_num = {"0"," One","Ii.","three","Restaurant","Wu","Lu","Qi","BA","JIU" }; Static string[] C_fh = {"","Pick","Bai","Qian" }; Static string[] C_wn = {"round","million","billion" }; Public Static stringConvertmoneytowords (decimalMoney ) { stringresult =string. Empty; if(!string. IsNullOrEmpty (Money. ToString ())) {string[] Moneysplit = money. ToString (). Split (New string[] {"."}, Stringsplitoptions.removeemptyentries); Regex Reg=NewRegex ("0 {2,}"); stringm = moneysplit[0]; intMlen =m.length; stringWord =string. Empty; for(inti = Mlen; i >0; i--) {Word= Convernumtoword (Word, m[mlen-i], I,true); } if(Moneysplit. Length >1) { stringD = moneysplit[1]; intDlen = d.length >2?2: d.length; if(Dlen = =2&& d[0] =='0'&& d[1] =='0') {Word+="Whole"; } Else { for(inti =0; i < Dlen; i++) {Word= Convernumtoword (Word, d[i], I,false); } } } Else{Word+="Whole"; } result= Reg. Replace (Word. ToString (),"0"); } returnresult; } Private Static stringConvernumtoword (stringAPPENDSTR,CharAintIndexBOOLIsyuan) { strings = C_num[convert.toint32 (a)- -]; if(Isyuan) {intz = (Index-1) /4; inty = (Index-1) %4; Appendstr= Appendstr + S + (s! ="0"? C_fh[y]:""); if(Y = =0) {Appendstr= Appendstr.trim ('0') +C_wn[z]; } } Else { if(Index = =0&& s! ="0") {Appendstr= Appendstr + S +"Angle"; } Else if(Index = =0) {Appendstr= Appendstr +s; } if(Index = =1&& s! ="0") {Appendstr= Appendstr + S +"points"; } } returnAppendstr; } }}
C # Money lowercase to uppercase algorithm