我希望我的错误消息显示在我的标签中(lblNewTemperature
)但是,每次我使用格式lblNewTemperature.Text = "Error message"
时,它都无法正常工作,并且与我混淆整体代码。知道为什么会这样吗?
if (!double.TryParse(txtTemperature.Text, out inputTemperature)) // Checking that user input is valid
{
MessageBox.Show("ERROR: Please enter a numeric temperature to convert."); // Error message that is displayed
txtTemperature.ResetText(); // Resets the form
txtTemperature.Focus(); // Places the user's cursor back in the Temperature textbox
}