title: Use of unassigned local variable error C#
body: <p>This is with regard to previous question posted a while ago
   <a href="https://stackoverflow.com/questions/12833433/remove-all-entry-with-1">Remove -1 entry from integer array</a></p>
  
  <p>I know there are blazing fast solutions , one line answers as posted in answer section  to previous posted question , but being a newbie I tried doing by for loops.</p>
  
  <pre><code>  int[] arr = new int[]{ 1, -1, -1, 1 };
              int[] new_arr;
              int index = 0;
              for (int i = 0; i &lt; arr.Length; i++)
              {
                 // Console.WriteLine(arr[i]);
                  if (arr[i] == -1)
                      continue;
                  else
                      new_arr[index++] = arr[i];
              }
  </code></pre>
  
  <p>I am getting error</p>
  
  <blockquote>
    <p>Use of unassigned local variable 'new_arr'</p>
  </blockquote>
  
  <p>what am I doing wrong.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>        int[] arr = new int[]{ 1, -1, -1, 1 };
          int[] new_arr = new[arr.Length]; //Error being shown at this line
          int index = 0;
          for (int i = 0; i &lt; arr.Length; i++)
          {
  
              if (arr[i] == -1)
                  continue;
              else
                  new_arr[index++] = arr[i];
          }
  
          for(int j=0;j&lt;new_arr.Length;j++)
              Console.WriteLine(new_arr[j]);
  </code></pre>