TrimZero方法
/// <summary>
/// 把数值末位的0去掉
/// </summary>
/// <param name="originalNumber"></param>
/// <returns></returns>
public string TrimZero(decimal originalNumber)
{
string result = System.Text.RegularExpressions.Regex.Replace(originalNumber.ToString(), @"(\.\d+?)[0]+$", "$1");
return System.Text.RegularExpressions.Regex.Replace(result, @"\.0$", "");
}
/// <summary>
/// 把数值末位的0去掉
/// </summary>
/// <param name="originalNumber"></param>
/// <returns></returns>
public string TrimZero(string originalNumber)
{
if (CommonFunction.CheckDecimal(originalNumber))
{
string result = System.Text.RegularExpressions.Regex.Replace(originalNumber, @"(\.\d+?)[0]+$", "$1");
return System.Text.RegularExpressions.Regex.Replace(result, @"\.0$", "");
}
else
{
return "0";
}
}
/// 把数值末位的0去掉
/// </summary>
/// <param name="originalNumber"></param>
/// <returns></returns>
public string TrimZero(decimal originalNumber)
{
string result = System.Text.RegularExpressions.Regex.Replace(originalNumber.ToString(), @"(\.\d+?)[0]+$", "$1");
return System.Text.RegularExpressions.Regex.Replace(result, @"\.0$", "");
}
/// <summary>
/// 把数值末位的0去掉
/// </summary>
/// <param name="originalNumber"></param>
/// <returns></returns>
public string TrimZero(string originalNumber)
{
if (CommonFunction.CheckDecimal(originalNumber))
{
string result = System.Text.RegularExpressions.Regex.Replace(originalNumber, @"(\.\d+?)[0]+$", "$1");
return System.Text.RegularExpressions.Regex.Replace(result, @"\.0$", "");
}
else
{
return "0";
}
}