title: c# System.NullReferenceException while assign the value to Enum array
body: <p>I want to add the value to null enum array. But I facing the null exception in run time. How can I fix this?</p>
  <p>My Enum is</p>
  <pre><code>public enum Name
  {
      Arun, Kumar, Mohan, Jerwin
  }
  </code></pre>
  <p>Then I create the enum array.</p>
  <pre><code>private static Name[] names; //here I can`t set the size. Because user can pass the input as per their need. 
  </code></pre>
  <p>Now I get the value from user and add to enum array collecction. But I facing null exception in the code.</p>
  <pre><code>public static string GetName(Name input)
  {
        names[0] = input;
        //My implementation            
  }
  </code></pre>
  <p>I am getting the error in the line <code>names[0] = input;</code>.</p>
  <p>My exception is</p>
  <blockquote>
  <p>An unhandled exception of type 'System.NullReferenceException' occurred in my.dll</p>
  <p>Additional information: Object reference not set to an instance of an object.</p>
  </blockquote>
  <p>How can I add this user input to enum array?</p>