今天看到N多人Blog大写金额转换函数,我也来凑个热闹,顺便换个思路
using System;
![]()
namespace Excellent.Data
{
/**//// <summary>
/// 金额类
/// </summary>
public sealed class Money
![]()
{
Variables#region Variables
private const string UNIT = "分角元拾佰仟万拾佰仟亿拾佰仟万";
private const string UPPER = "零壹贰叁肆伍陆柒捌玖";
#endregion
![]()
Properties#region Properties
![]()
#endregion
![]()
Constructors#region Constructors
![]()
#endregion
![]()
Overrides#region Overrides
![]()
#endregion
![]()
Methods#region Methods
/**//// <summary>
/// 获取大写金额
/// </summary>
/// <param name="lower">小写金额</param>
/// <returns>string</returns>
public static string GetUpper(decimal lower)
![]()
{
string stResult = "", stLower = "";
![]()
stLower = lower.ToString("0.00").Replace(".", "");
if (stLower.Length <= UNIT.Length)
![]()
{
for (int i = 0, j = stLower.Length - 1; i <= j; i ++)
![]()
{
stResult += UPPER[stLower[i] - 48].ToString() + UNIT[j - i].ToString();
}
}
else
![]()
{
stResult = "#E";
}
![]()
return stResult;
}
#endregion
}
}
![]()
