double m = 1234222.010;
string s1 = FormatValue(Convert.ToDecimal(m.ToString("0")));网上的 方法: private string FormatValue(decimal value)
{
StringBuilder sb = new StringBuilder(); string sValue = value.ToString(); List<string> list = new List<string>(); string temp = sValue; bool includeFloat = sValue.LastIndexOf(".") != -1; if (includeFloat)
{
//temp = temp.Substring(0, sP);
temp = ((int)value).ToString();
} int templength = temp.Length; if (temp.Length > 3)
{
while (templength > 3)
{
list.Add(temp.Substring(templength - 3, 3));
templength -= 3;
} //最前面的添加进来
list.Add(temp.Substring(0, temp.Length - list.Count * 3)); for (int i = list.Count - 1; i > 0; i--)
{
sb.Append(list[i] + ",");
}
sb.Append(list[0]); if (includeFloat)
{
sb.Append(sValue.Substring(sValue.LastIndexOf(".")));
}
}
else
{
return sValue;
}
return sb.ToString();
}
double value = 16325.62;
var s = value.ToString("#,#.##");
f.ToString("###,###,###,###,###,##0‰");