if (!char.TryParse(txtCustomerName.Text, out charCustomerName)) //try to read in Layers from TextBox
{
MessageBox.Show("Customer Name must be entered.", "Invalid Customer Name");
return;
}
if (!Decimal.TryParse(txtAmountOwed.Text, out decAmountOwed)) //try to read in Layers from TextBox
{
MessageBox.Show("Amount Owed must be entered without dollar signs or commas.", "Invalid Amount Owed");
return;
}
if (!int.TryParse(txtDaysOverdue.Text, out intDaysOverdue)) //try to read in Layers from TextBox
{
MessageBox.Show("Days Overdue must be entered as a whole number.", "Invalid Days Overdue");
return;
}当我运行程序时,它告诉我必须输入客户名称,即使我输入了它。我该如何改变这一点?
发布于 2015-02-06 22:54:53
替换
if (!char.TryParse(txtCustomerName.Text, out charCustomerName)) 使用
if (String.IsNullOrEmpty(txtCustomerName.Text)) char仅表示一个字符
https://stackoverflow.com/questions/28368431
复制相似问题