Copy codeThe Code is as follows:
Public static string ConvertToChineseMoney (double money)
{
If (money <0)
Throw new ArgumentOutOfRangeException ("the parameter money cannot be a negative value! ");
String s = money. toString ("# L # E # D # C # K # E # D # C # J # E # D # C # I # E # D # C # H # E # D # C # G # E # D # C # F # E # D # C #. 0B0A ");
S = Regex. Replace (s ,@"((? <=-| ^) [^ 1-9] *) | ((? 'Z' 0) [0A-E] * (? = [1-9]) | (? '-Z '(? = [F-L \.] | $) | ((? 'B' [F-L]) (? 'Z' 0) [0A-L] * (? = [1-9]) | (? '-Z '(? = [\.] | $) "," $ {B }$ {z }");
Return Regex. replace (s ,". ", delegate (Match m) {return" negative element null 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3. value [0]-']. toString ();});
}
Call this method:
Copy codeThe Code is as follows:
Random r = new Random ();
For (int I = 0; I <10; I ++)
{
Double MB = r. Next ()/100.0;
Response. Write (m + "----" + ConvertToChineseMoney (m) + "<br/> ");
}
Running result:
5970370.36 ---- Wu yunqi pick up the points and points
6521548.6 ---- Lu Yi Wu Xi Si Xi Yuan Lu Jiao
12179380.35 ---- yi Cheng
15742735.47 ---- Yi Wu Yu, Xiao Si, Xiao Yu, Wu Yuan Si Jiao Min
9236554.09 ---- yuan
9706980.49 ---- just pick up the yuan and then pick up the yuan
11873034.16 ---- yi Yu Yi Qi Si Yuan Yi Jiao Lu fen
21141596.22 ---- just a few minutes, just a few minutes.
17040243.44 ---- yi si
5358585.54 ---- Wu yunqi Wu Yunxiao