title: C# Unreachable code (Property-dependant array copier )
body: <p>I have an array, with number ranging from -100 to 100. Now, I have to make a method that copies the positive ones into an other array.
  I made this:</p>
  
  <pre><code>static int[] ArrayCopy(int[] t)
      {
          int a = 0;
          int[] g = new int[0];
          for (int i = 0; i &lt; t.Length; i++)
          {
              if (t[i] &gt; 0)
              {
  
                  g[a] = t[i];
                  a++;
  
              }
  
          }
          return g;
  
       }
  </code></pre>
  
  <p>The program terminates with IndexOutOfRange, and I don't get it.</p>