DataTime.Now.Ticks的应用

参考:http://www.cnblogs.com/delphinet/archive/2011/06/09/2075985.html

 

转换成秒:

using System;  
using System.Collections.Generic;  
  
class Sentence  
{  
  static void Main()  
  {  
    long ticks0 = DateTime.Now.Ticks;  
    for (int i = 0; i < int.MaxValue; i++)  
    {  
      // ...  
    }  
    long ticks1 = DateTime.Now.Ticks;  
    double n = (ticks1 - ticks0) / 10000000.0;  
    Console.WriteLine("上面这段程序运行了{0}秒", n);  
  }  
}  

 

posted @ 2016-02-16 18:52  ChineseMoonGod  阅读(224)  评论(0编辑  收藏  举报