过虑数字类型后面的0
//Author:quietwalk
//Date:2011-06-13
//Operation:过滤数字型数据的后面的0,保证只有一个0
//输入:45.000
//输出:45.0
public static string trim0(string ls_original)
{
int iLength, j;
j = 0;
//iLength=len(ls_original);
iLength = ls_original.Length;
string ls_temp;
ls_temp = ls_original;
string strR1;
if (iLength > 2)
{
//strR1=right(ls_original,1);
strR1 = ls_original.Substring(ls_original.Length - 1, 1);
do
{
j++;
//ls_temp=left(ls_original,iLength - j);
ls_temp = ls_original.Substring(0, iLength - j);
//strR1=right(ls_temp,1);
strR1 = ls_temp.Substring(ls_temp.Length - 2, 1);
}
while (strR1 == "0");
}
//如果被删除光了,说明它原来就是0
if (ls_temp == "")
{
ls_temp = "0";
}
//如果最后一个字符是".",再在后面加个"0"
//strR1 = right(ls_temp, 1);
strR1 = ls_temp.Substring(ls_temp.Length - 1, 1);
if (strR1 == ".")
{
ls_temp = ls_temp + "0";
}
return ls_temp;
}//end