用一些关键的数据试验一下:
using System;namespace JustTest
{
class Program
{
static void Main(string[] args)
{
double test = 111.1234;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); test = 10.1;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); test = 100.12;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); test = 1000.12;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); test = 10000.12;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); Console.ReadLine();
}
} public class Test
{
public static String CoverLoToStr(double lo)
{
String s = lo.ToString("f0");
while (s.Length < 3)
s = "0" + s;
lo = (lo - (int)lo) * 60;
String s1 = lo.ToString("f3");
while (s1.Length < 6)
s1 = "0" + s1;
return s + s1;
} public static String CoverLaToStr(double la)
{
String s = la.ToString("f0");
while (s.Length < 2)
s = "0" + s;
la = (la - (int)la) * 60;
String s1 = la.ToString("f3");
while (s1.Length < 6)
s1 = "0" + s1;
return s + s1;
}
}
}
using System;namespace JustTest
{
class Program
{
static void Main(string[] args)
{
double test = 111.1234;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); test = 10.1;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); test = 100.12;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); test = 1000.12;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); test = 10000.12;
Console.WriteLine("{0}转换后La:{1}", test, Test.CoverLaToStr(test));
Console.WriteLine("{0}转换后Lo:{1}", test, Test.CoverLoToStr(test));
Console.WriteLine("======================================================="); Console.ReadLine();
}
} public class Test
{
public static String CoverLoToStr(double lo)
{
String s = lo.ToString("f0");
while (s.Length < 3)
s = "0" + s;
lo = (lo - (int)lo) * 60;
String s1 = lo.ToString("f3");
while (s1.Length < 6)
s1 = "0" + s1;
return s + s1;
} public static String CoverLaToStr(double la)
{
String s = la.ToString("f0");
while (s.Length < 2)
s = "0" + s;
la = (la - (int)la) * 60;
String s1 = la.ToString("f3");
while (s1.Length < 6)
s1 = "0" + s1;
return s + s1;
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货