So I am getting a message when I do the following instruction:
"Unnecessary assignment of a value to 'dec'" which is not really unnecessary because TryParse() requires it. Is there a better way to do this, though?
Code:
if (txtUnitPrice.Text != "" && !decimal.TryParse(txtUnitPrice.Text, out decimal dec))
{
MessageBox.Show("Please enter a numeric value in the Price field or leave blank.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txtUnitPrice.Focus();
return false;
}