Watch time

 1    Stopwatch watch = new Stopwatch();
 2             watch.Start();
 3           
 4             for (int i = 0; i <= 9; i++)
 5             {
 6                 for (int j = 0; j <= 9; j++)
 7                 {
 8                     for (int k = 0; k <= 9; k++)
 9                     {
10                         for (int m = 0; m <= 9; m++)
11                         {
12                             if (i + "" + j + "" + k + "" + m == "8549")
13                             {
14                                 watch.Stop();
15 
16                                 // Get the elapsed time as a TimeSpan value.
17                                 TimeSpan ts = watch.Elapsed;
18 
19                                 // Format and display the TimeSpan value.
20                                 string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
21                                     ts.Hours, ts.Minutes, ts.Seconds,
22                                     ts.Milliseconds / 10);
23                                 Console.WriteLine("RunTime " + elapsedTime);
24                                 Console.ReadLine();
25                             }
26                            
27                             
28                         }
29                     }
30                 }

 

posted @ 2017-11-16 16:36  ~扎克伯格  阅读(432)  评论(0编辑  收藏  举报