using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace EqualsTesting { class Program { static void Main(string[] args) { string one = "Hello"; Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 10000; i++) if (one == null || one.Length == 0) Console.Write(""); sw.Stop(); Console.WriteLine("if (one == null || one.Length == 0) ran 10000 times in {0} ms", sw.Elapsed); sw.Reset(); sw.Start(); for (int i = 0; i < 10000; i++) if (one.Equals(null) || one.Equals("")) Console.Write(""); sw.Stop(); Console.WriteLine("if (one.Equals(null) || one.Equals(\"\")) ran 10000 times in {0} ms", sw.Elapsed); sw.Reset(); sw.Start(); for (int i = 0; i < 10000; i++) if (string.IsNullOrEmpty(one)) Console.Write(""); sw.Stop(); Console.WriteLine("if (string.IsNullOrEmpty(one)) ran 10000 times in {0} ms", sw.Elapsed); Console.ReadLine(); } } }