Solution A,
you can use two arrays. One for the numbers one for the corresponding weights.
public double[] _number = new double[] {67,54,98};
public double[] _weights = new double[] {32,12,45};
then:
double _wavg = 0;
for(int i = 0; i < _number.Count(); i++)
{
_wavg += ((_number[i] * _weight[i]) / (_weights.Sum())
}
Solution B,
You can use a predefined class to store your numbers end weights
public class WeightedNumber
{
public double Number {get; set; }
public double Weight{get; set; }
}
List<wightednumber> _numbers;</wightednumber>
The rest looks more or less the same