2。protected string FormatMoney(string FMoney)
{
string money = FMoney;
int postion = 0;
if (money.IndexOf('.') < 0)
{
postion = money.Length;
}
else
{
postion = money.IndexOf('.');
}
int maxfor = postion / 3;
int re = (int)postion % 3;
StringBuilder aa = new StringBuilder();
if (re != 0)
{
aa.Append(money.Substring(0, re));
for (int i = 0; i < maxfor; i++)
{
aa.Append(",");
aa.Append(money.Substring(re, 3));
re = re + 3;
}
}
else
{
re = 3;
aa.Append(money.Substring(0, re));
for (int j = 0; j < maxfor - 1; j++)
{
aa.Append(",");
aa.Append(money.Substring(re, 3));
re = re + 3;
}
}
aa.Append(money.Substring(postion));
return aa.ToString();
}