测试平台:XP,VS2005 C#,32位
测试代码
static void Main(string[] args)
{
string StrTest = "asdfas";
Console.WriteLine(DateTime.Now);
Console.WriteLine(DateTime.Now.Millisecond);
for (long i = 0; i <= 10000000; i++)
{
if (StrTest.Length==0)
{
Console.Write(i);
}
}
Console.WriteLine(DateTime.Now);
Console.WriteLine(DateTime.Now.Millisecond);
Console.Read();
}
空字符串比较
StrTest.Length==0比StrTest==""的速度快一倍
循环变量
int比long的速度快接近一倍
待续……