例如
txtUnitTotalQty.Text = "";
txtPrice.Text = "";
txtUnitPrice.Text = "";
lblTotalvalue.Text = "";
Run Code Online (Sandbox Code Playgroud)
喜欢的东西
(txtUnitTotalQty, txtPrice, txtUnitPrice, lblTotalvalue).Text = "";
Run Code Online (Sandbox Code Playgroud)
你可以这样做:
txtUnitTotalQty.Text = txtPrice.Text = txtUnitPrice.Text = lblTotalvalue.Text = string.Empty;
Run Code Online (Sandbox Code Playgroud)
或者你可以为它编写一个方法:
public void SetText(params TextBox[] controls, string text)
{
foreach(var ctrl in controls)
{
ctrl.Text = text;
}
}
Run Code Online (Sandbox Code Playgroud)
使用方法是:
SetText(txtUnitTotalQty, txtPrice, txtUnitPrice, lblTotalvalue, string.Empty);
Run Code Online (Sandbox Code Playgroud)