我有這個method
這些textboxes
SUM
價值觀,我想改善它,如果任何這些textboxes
的是empty
我想插入它"0"
這可是我沒有」 t知道在哪裏,以及如何使它像我想要的那樣工作。我很長時間以來一直在想這個,有人會告訴我一些事嗎?當一個文本框爲空,如何輸入一個默認值
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();
}
感謝大家的幫助和時間。
的WinForms或WPF? – sircodesalot
@sircodesalot WinForms,謝謝你的時間。 – Marek