111,126
社区成员
发帖
与我相关
我的任务
分享public static void GetLength()
{
double d = 456655445.123;//测试数据
string s = Convert.ToString(d);
if (s.IndexOf(".") != -1)
{
int len = s.Length - (s.IndexOf(".") + 1);
Console.WriteLine(String.Format("小数位数为:{0}",len));
}
else
{
Console.WriteLine(String.Format("小数位数为:{0}", 0));
}
Console.Read();
}
string i = "456655445.125445";
MessageBox.Show("其小数为:" + i.Substring(i.IndexOf(".") + 1, i.Length - (i.IndexOf(".") + 1)) + " 小数的位数为:" + i.Substring(i.IndexOf(".") + 1, i.Length - (i.IndexOf(".") + 1)).Length.ToString());