title: Fastest method for copying a string array in C# - direct assigning or using Copy(), CopyTo() or Clone()
body: <p>I tried to find out which is the fastest method for copying a string array by using this code:</p>
  
  <pre><code>static void Main(string[] args)
      {
          Stopwatch copy = new Stopwatch();
          Stopwatch copyTo = new Stopwatch();
          Stopwatch direct = new Stopwatch();
          Stopwatch clone = new Stopwatch();
  
          string[] animals = new string[1000];
          animals[0] = "dog";
          animals[1] = "cat";
          animals[2] = "mouse";
          animals[3] = "sheep";
          for (int i = 4; i &lt; 1000; i++)
          {
              animals[i] = "animal";
          }
  
          copy.Start();
          string[] copyAnimals = new string[animals.Length];
          Array.Copy(animals, copyAnimals, animals.Length);
          copy.Stop();
          Console.WriteLine("Copy: " + copy.Elapsed);
  
          copyTo.Start();
          string[] copyToAnimals = new string[animals.Length];
          animals.CopyTo(copyToAnimals, 0);
          copyTo.Stop();
          Console.WriteLine("Copy to: " + copyTo.Elapsed);
  
          direct.Start();
          string[] directAnimals = new string[animals.Length];
          directAnimals = animals;
          direct.Stop();
          Console.WriteLine("Directly: " + direct.Elapsed);
  
          clone.Start();
          string[] cloneAnimals = (string[])animals.Clone();
          clone.Stop();
          Console.WriteLine("Clone: " + clone.Elapsed);
  
      }
  </code></pre>
  
  <p>In most cases the ranking by fastest is: CopyTo(), Clone(), Directly, Copy(), however it is not absolutely consistent. What is your experience? Which one do you use the most and why?</p>