標籤:os ar for sp on c ef r new
- /// <summary>
- /// 輸入Float格式數字,將其轉換為貨幣表達方式
- /// </summary>
- /// <param name="ftype">貨幣表達類型:0=帶¥的貨幣表達方式;1=不帶¥的貨幣表達方式;其它=帶¥的貨幣表達方式</param>
- /// <param name="fmoney">傳入的int數字</param>
- /// <returns>返迴轉換的貨幣表達形式</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>
- /// 輸入Float格式數字,將其轉換為貨幣表達方式
- /// </summary>
- /// <param name="ftype">貨幣表達類型:0=人民幣;1=港幣;2=美鈔;3=英鎊;4=不帶貨幣;其它=不帶貨幣表達方式</param>
- /// <param name="fmoney">傳入的int數字</param>
- /// <returns>返迴轉換的貨幣表達形式</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");//中國大陸
- _rmoney = fmoney.ToString("c", cul);
- break;
- case 1:
- cul = new CultureInfo("zh-HK");//香港
- _rmoney = fmoney.ToString("c", cul);
- break;
- case 2:
- cul = new CultureInfo("en-US");//美國
- _rmoney = fmoney.ToString("c", cul);
- break;
- case 3:
- cul = new CultureInfo("en-GB");//英國
- _rmoney = fmoney.ToString("c", cul);
- break;
- case 4:
- _rmoney = string.Format("{0:n}", fmoney);//沒有貨幣符號
- break;
- default:
- _rmoney = string.Format("{0:n}", fmoney);
- break;
- }
- }
- catch
- {
- _rmoney = "";
- }
- return _rmoney;
- }
C#.net 貨幣格式轉換