How to calculate the sum of specific Array Elements using vb.net
<p>I have two arrays</p>

<pre><code>x = [1 1 1 0 2 3 1 1]

y = [1 2 3 4 5 6 7 8]
</code></pre>

<p>How to calculate the sum of y's elements for all <code>x(i) = 1</code> to get the result <code>1+2+3+7+8</code> ?</p>

<p>I have used for loop and if then method to calculate the sum value like this</p>

<p><code>if x(i) = 1  then sum = sum + y(i)</code></p>

<p>Have other methods to get the results (sum, average, count ...) ?</p>

<p>Thank you.</p>