nullreferenceexception was unhandled on filling up array - c#
<p>I am trying  to retrieve all names that was saved at the sql database<br>
then suddenly I got the </p>

<blockquote>
  <p>nullreferenceexception was unhandled on filling up array - Object
  reference not set to an instance of an object.</p>
</blockquote>

<p>this was my code:</p>

<p>I got the error at the </p>

<pre><code>  imgName[i] = Convert.ToString(dt.Rows[i]["FinalImageName"]);  
</code></pre>

<p>in that part, I'd like to fill imgName array all the name  </p>

<p>how could i fix it?, help please</p>

<pre><code>string c_string = "server=.\\sqlexpress;database=Blue;trusted_connection=true";

public static string ImageToShow;
private int NumOfFiles;
private string[] imgName;

SqlConnection c = new SqlConnection(c_string);
//SqlCommand cm = new SqlCommand(cmd,c);

private void frmMain_Load(object sender, EventArgs e) {
    SqlConnection c = new SqlConnection(c_string);

    try {
        c.Open();
    }
    catch (SqlException ee) {
        MessageBox.Show(ee.Message);
    }
    finally {
        c.Close();
    }
    updateData();
}

private void updateData() {

    SqlConnection c = new SqlConnection(c_string);

    SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM FinalImages", c);

    DataTable dt = new DataTable();
    da.Fill(dt);

    NumOfFiles = dt.Rows.Count;
    for (int i = 0; i &lt; dt.Rows.Count; i++) {
        imgName[i] = Convert.ToString(dt.Rows[i]["FinalImageName"]);

    }
}​
</code></pre>
