C# - How to sum values of a generic list?
<p>I would like to get the sum of the <code>val</code> field.</p>

<pre><code>// member method 
public T sum()
{
    sum = default(T);
    int i = 0;
    while (i &lt; size)
        sum += val[i++];
}

private int size = 0;
private int usedSize = 0;
private T[] val = null;
</code></pre>