我想在控制台中只收到as_x的1个值,但我总是得到2个值,其中一个完全错误,如“无穷大”,“未定义”或奇怪的值。 “压力”包含3个显示的“枚举”值。 我想要做的是在最后计算as_x。因此,根据lookupValuemux,我得到一个omega的值。并且根据omega的值,有3种不同的方法来计算as_x。 我是编程的真正初学者,所以任何帮助都会很棒。
double omega;
double as_x;
pressure design;
double M_Eds_lim = 0.296 * Math.Pow(d, 2) * (fck * design_force.alpha_cc / design_force.gamma_c);
double delta_M_Ed = mx - M_Eds_lim;
omega = 0;
design = 0;
as_x = 0;
double mux = mx / (Math.Pow(d, 2) * (fck * design_force.alpha_cc / design_force.gamma_c));
double lookupValuemux = Math.Round(mux, 2);
if (lookupValuemux < 0.01) {
design = pressure.min;
} else if ((lookupValuemux >= 0.01) && (lookupValuemux < 0.30)) {
design = pressure.tension;
omega = design_force.omegaTable[lookupValuemux][0];
} else if (lookupValuemux >= 0.30); {
design = pressure.steel;
omega = 0.3643;
};
if (design == pressure.min) {
as_x = As_min;
Console.WriteLine("asx ID " + ID + "asx = " + as_x);
} else if (design == pressure.tension) {
as_x = omega * d * (fck * design_force.alpha_cc / design_force.gamma_c) / (f_yk / design_force.gamma_s);
Console.WriteLine("asx ID " + ID + "asx = " + as_x);
} else if (design == pressure.steel); {
as_x = omega * d * (fck * design_force.alpha_cc / design_force.gamma_c) / (f_yk / design_force.gamma_s) + delta_M_Ed / (d - d_2) / (f_yk / design_force.gamma_s);
Console.WriteLine("asx ID " + ID + "asx = " + as_x);
}
答案 0 :(得分:1)
在未经编辑的原始帖子中,这一行最后有一个虚假的分号:
else if (design == pressure.steel);
这已由OP以外的其他人编辑(也不是由dasblinkenlight编辑),因此分号不再出现在问题中。
由于这是导致as_x
被打印两次的原因,因此将其删除是无益的。
请注意,此行中还有另一个多余的分号:
} else if (lookupValuemux >= 0.30); {
也应该删除。
这是原帖的后半部分出现的原因:
if (design == pressure.min)
{
as_x = As_min;
Console.WriteLine("asx ID " + ID + "asx = " + as_x);
}
else if (design == pressure.tension)
{
as_x = omega * d * (fck * design_force.alpha_cc / design_force.gamma_c) / (f_yk / design_force.gamma_s);
Console.WriteLine("asx ID " + ID + "asx = " + as_x);
}
else if (design == pressure.steel); // <---- LOOKIE HERE
{
as_x = omega * d * (fck * design_force.alpha_cc / design_force.gamma_c) / (f_yk / design_force.gamma_s) + delta_M_Ed / (d - d_2) / (f_yk / design_force.gamma_s);
Console.WriteLine("asx ID " + ID + "asx = " + as_x);
}