public void Calculate() { //get values from in pipes, and write result to all outpipes. float result = 0; Queue <IPipe> inputs = new Queue <IPipe>(inp); IPipe current; while (inputs.TryDequeue(out current)) { float weight = current.GetWeightBais().Item1; float bias = current.GetWeightBais().Item2; result += (current.GetValue() + bias) * weight; } outp.SetValue(result); }