- <summary>
- Enter float format number to convert it to currency expression
- </summary>
- <param name= "ftype" > Currency expression type: 0 = currency expression with ¥, 1 = currency expression without ¥; other = currency expression with ¥ </param>
- <param name= "Fmoney" > incoming int number </param>
- <returns> returns the currency representation of the conversion </returns>
- Public string Rmoney (int ftype, double fmoney)
- {
- String _rmoney;
- Try
- {
- Switch (ftype)
- {
- Case 0:
- _rmoney = string. Format ("{0:c2}", Fmoney);
- Break
- Case 1:
- _rmoney = string. Format ("{0:n2}", Fmoney);
- Break
- Default
- _rmoney = string. Format ("{0:c2}", Fmoney);
- Break
- }
- }
- Catch
- {
- _rmoney = "";
- }
- return _rmoney;
- }
- <summary>
- Enter float format number to convert it to currency expression
- </summary>
- <param name= "ftype" > Currency expression type: 0 = RMB, 1 = HKD, 2= dollar, 3 = GBP; 4 = no currency; other = no currency expression </param>
- <param name= "Fmoney" > incoming int number </param>
- <returns> returns the currency representation of the conversion </returns>
- Public static string convertcurrency (decimal fmoney)
- {
- CultureInfo cul = null;
- int ftype=4;
- String _rmoney=string. Empty;
- Try
- {
- Switch (ftype)
- {
- Case 0:
- Cul = new CultureInfo ("ZH-CN"); Mainland China
- _rmoney = Fmoney. ToString ("C", cul);
- Break
- Case 1:
- Cul = new CultureInfo ("zh-hk"); Hong Kong
- _rmoney = Fmoney. ToString ("C", cul);
- Break
- Case 2:
- Cul = new CultureInfo ("en-us"); United States
- _rmoney = Fmoney. ToString ("C", cul);
- Break
- Case 3:
- Cul = new CultureInfo ("EN-GB"); United Kingdom
- _rmoney = Fmoney. ToString ("C", cul);
- Break
- Case 4:
- _rmoney = string. Format ("{0:n}", Fmoney); No currency symbol
- Break
- Default
- _rmoney = string. Format ("{0:n}", Fmoney);
- Break
- }
- }
- Catch
- {
- _rmoney = "";
- }
- return _rmoney;
- }
C#.net Currency format Conversion