将一个千以上的数字数据转换为使用‘,’分隔的字符串的方法
/// <summary>
/// 转换数字为使用‘,’分隔的字符串
/// </summary>
/// <param name="src">数字值</param>
/// <returns>转换后的数字字符串</returns>
public string ConvertInt(int src)
{
string result = "";
if (System.Math.Abs(src) < 1000) //大于1000才需要转换,如果不是就不用转换直接得到字符串
result = src.ToString();
else
{
result = src.ToString().Substring(src.ToString().Length - 3, 3);
}
int quotient = src / 1000;
if (System.Math.Abs(quotient) > 0)
{
result = ConvertInt(quotient) + "," + result;
}
return result;
}