C# Can't iterate through string array
<p>I am trying to iterate through a string array and if it contains a certain string add 1 to an integer but I'm getting an error on the if statement saying:</p>

<pre><code> NUllReferenceException is unhandled
 Object reference not set to an instance of an object
</code></pre>

<p>/</p>

<pre><code> for (int i = 0; i &lt; GlobalData.CellH.Length; i++)
        {
            if (GlobalData.CellH[i].Contains("M"))
            {
                GlobalData.TotalBoys++;
            }
            else if (GlobalData.CellH[i].Contains("F"))
            {
                GlobalData.TotalGirls++;
            }
            else if (GlobalData.CellH[i].Contains(null))
            {
            }
        }
</code></pre>

<p><strong>FIXED:</strong></p>

<pre><code> for (int i = 0; i &lt; GlobalData.CellH.Length; i++)
        {
            if (GlobalData.CellH[i] == "M")
            {
                GlobalData.TotalBoys++;

            }
            else if (GlobalData.CellH[i] == "F")
            {
                GlobalData.TotalGirls++;
            }
            else if (GlobalData.CellH[i] == "")
            {
            }
        }
</code></pre>
