Use regular expressions in C # to convert RMB amounts to uppercase characters _android

Source: Internet
Author: User

Look at the code directly:

public static string Converttochinesemoney (double) 
  { 
    if (Money < 0) 
      throw new ArgumentOutOfRangeException ("parameter money cannot be negative!") "); 
    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 Yuan 0 a third Woolu qi ba Shing empty empty points to collect the million trillion Beijing gai 秭 rang" [m.value[0]-'-']. ToString (); }); 
  } 

Call this method:

Random r = new Random (); 
for (int i = 0; i < i++) 
{ 
  Double m = r.next ()/100.0; 
  Response.Write (M + "----" + Converttochinesemoney (m) + "<br/>"); 
} 

To test, the results are as follows:

5970370.36----Wu Ying, QI, 6521548.6, seven, Nine, Ten, ten, three,----, Wu Bai Wu to pick up the Ba Yuan Lu Kok 12179380.35----A thousand thousands of thousands of thousands of thousands of thousands of thousands of

BA to collect the three-

point Wood 15742735.47----Wu bai qi qi bai qi Wu Yuan jiao qi 9236554.09----Nine to pick up three Lu Ying Wu Wu to pick up Yuan points 9706980.49----nine million Qi Lu Ying

Bai ba pick Yuan restaurant corner nine points 11873034.16----One thousand thousand thousands of BA seven thousands of 0 to pick up a corner of the 21141596.22----, one by one, one by one, to pick up the Lu Yuan of the

seven-point Wu Ying 17040243.44

---- Seven hundred 0 establishments to pick up three yuan in the

5358585.54----Wu Bai Ba Wu Wu ba pick up Wu Yuan Wu Kok restaurant points

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.