Where to declare variable?
<p>I am trying to make an average function. <code>Total</code> adds the values, then <code>Total</code> is divided by <code>n</code>, the number of entries.</p>

<p>No matter where I put <code>double Total;</code>, I get an error message. In this example I get the exception:</p>

<pre>
    Use of unassigned local variable 'Total'
</pre>

<p>If I put it before the <code>Average</code> method, both references show up as error. I'm sure it's something simple ...</p>

<pre><code>namespace frmAssignment3
{
    class StatisticalFunctions
    {
        public static class Statistics
        {
            public static double Average(List&lt;double&gt; argMachineDataList)
            {
                double Total;

                int n;
                for (n = 1; n &lt;= argMachineDataList.Count; n++) {
                    Total = argMachineDataList[n];
                }

                return Total / n;
            }

            public static double StDevSample(
                List&lt;MachineData.MachineRecord&gt; argMachineDataList)
            {
                return -1;
            }
        }
    }
}
</code></pre>
