监测程序运行时间的类

class Program
   
        public static void Main(string[] args)
        {
            Stopwatch sw = new Stopwatch();
            object s="";
            sw.Start();
            for (int i = 0; i < 100000; i++)
            {
                if (s == null)
                {
                    Console.WriteLine("不为空");
                }
                ++i;
            }
            sw.Stop();
            Console.WriteLine(sw.Elapsed);
            sw.Reset();
            sw.Start();
            for (int i = 0; i < 100000; i++)
            {
                if (s == DBNull.Value)
                {
                    Console.WriteLine("不为空");
                }
                ++i;
            }
            sw.Stop();
            Console.WriteLine(sw.Elapsed);
            Console.ReadKey();
            //if (!DBNull.Value.Equals(s))
            //{
            //    Console.WriteLine("不为空");
            //}
       
    }ide

相关文章
相关标签/搜索