【发布时间】:2013-07-27 23:51:46
【问题描述】:
我有这个method SUM 在那些textboxes 中的值,我想改进它所以如果这些textboxes 中的任何一个是empty 我想插入它"0" 但我没有不知道去哪里以及到底放了什么让它像我想要的那样工作。这个问题我想了很久,请问有大神推荐一下吗?
void vypocti_naklady()
{
double a, b,c,d,e,f,g,h;
if (
!double.TryParse(p_ub_s.Text, out a) ||
!double.TryParse(p_poj_s.Text, out b) ||
!double.TryParse(p_jin_s.Text, out c) ||
!double.TryParse(p_dop_s.Text, out d) ||
!double.TryParse(p_prov_s.Text, out e) ||
!double.TryParse(p_pruv_s.Text, out f) ||
!double.TryParse(p_rez_s.Text, out g) ||
!double.TryParse(p_ost_s.Text, out h)
)
{
naklady.Text = "0";
return;
}
naklady.Text = (a+b+c+d+e+f+g+h).ToString();
}
感谢大家的帮助和时间。
【问题讨论】:
-
@sircodesalot WinForms,感谢您抽出宝贵时间。
标签: c# winforms methods textbox operand