自测装箱/拆箱
结果:
time1:00:00:00.3
time2:00:00:01.5
--------------------------
代码:
object obj = null;
int iTest = -1;
int iRet = -1;
DateTime dt1 = System.DateTime.Now;
for(int i=0;i<iCount;i++)
{
iTest = i;
iRet = iTest;
}
TimeSpan time1 = System.DateTime.Now.Subtract(dt1);
Console.WriteLine("time1:"+time1.ToString());
DateTime dt2 = System.DateTime.Now;
for(int j=0;j<iCount;j++)
{
obj = j;
iRet = (int)obj;
}
TimeSpan time2 = System.DateTime.Now.Subtract(dt2);
Console.WriteLine("time2:"+time2.ToString());
Console.Read();