C#零碎知识汇总

1.取时间差

时刻:DateTime      时差:TimeSpan

C#零碎知识汇总_第1张图片

代码:

1         DateTime time1 = DateTime.Now; 2         textBox1.Text = time1.ToString(); 3         for (int i = 0; i < 5000; i++) 4             for (int j = 0; j < 5000; j++) 5  ; 6         DateTime time2 = DateTime.Now; 7         textBox2.Text = time2.ToString(); 8         TimeSpan time = time2.Subtract(time1).Duration(); 9         textBox3.Text = time.ToString();

 

你可能感兴趣的:(C#零碎知识汇总)