C#.net Currency format Conversion

Source: Internet
Author: User

  1. <summary>
  2. Enter float format number to convert it to currency expression
  3. </summary>
  4. <param name= "ftype" > Currency expression type: 0 = currency expression with ¥, 1 = currency expression without ¥; other = currency expression with ¥ </param>
  5. <param name= "Fmoney" > incoming int number </param>
  6. <returns> returns the currency representation of the conversion </returns>
  7. Public string Rmoney (int ftype, double fmoney)
  8. {
  9. String _rmoney;
  10. Try
  11. {
  12. Switch (ftype)
  13. {
  14. Case 0:
  15. _rmoney = string.  Format ("{0:c2}", Fmoney);
  16. Break
  17. Case 1:
  18. _rmoney = string.  Format ("{0:n2}", Fmoney);
  19. Break
  20. Default
  21. _rmoney = string.  Format ("{0:c2}", Fmoney);
  22. Break
  23. }
  24. }
  25. Catch
  26. {
  27. _rmoney = "";
  28. }
  29. return _rmoney;
  30. }
  31. <summary>
  32. Enter float format number to convert it to currency expression
  33. </summary>
  34. <param name= "ftype" > Currency expression type: 0 = RMB, 1 = HKD, 2= dollar, 3 = GBP; 4 = no currency; other = no currency expression </param>
  35. <param name= "Fmoney" > incoming int number </param>
  36. <returns> returns the currency representation of the conversion </returns>
  37. Public static string convertcurrency (decimal fmoney)
  38. {
  39. CultureInfo cul = null;
  40. int ftype=4;
  41. String _rmoney=string.  Empty;
  42. Try
  43. {
  44. Switch (ftype)
  45. {
  46. Case 0:
  47. Cul = new CultureInfo ("ZH-CN"); Mainland China
  48. _rmoney = Fmoney.  ToString ("C", cul);
  49. Break
  50. Case 1:
  51. Cul = new CultureInfo ("zh-hk"); Hong Kong
  52. _rmoney = Fmoney.  ToString ("C", cul);
  53. Break
  54. Case 2:
  55. Cul = new CultureInfo ("en-us"); United States
  56. _rmoney = Fmoney.  ToString ("C", cul);
  57. Break
  58. Case 3:
  59. Cul = new CultureInfo ("EN-GB"); United Kingdom
  60. _rmoney = Fmoney.  ToString ("C", cul);
  61. Break
  62. Case 4:
  63. _rmoney = string. Format ("{0:n}", Fmoney); No currency symbol
  64. Break
  65. Default
  66. _rmoney = string.  Format ("{0:n}", Fmoney);
  67. Break
  68. }
  69. }
  70. Catch
  71. {
  72. _rmoney = "";
  73. }
  74. return _rmoney;
  75. }

C#.net Currency format Conversion

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.