过虑数字类型后面的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
?
總結
以上是生活随笔為你收集整理的过虑数字类型后面的0的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 去掉button按钮左右两边的留白
- 下一篇: win7下注册一个com失败,权限不够