I have a simple program which calculates totals. I have added a line of code which will display a message box when a non-numerical value is entered.
The working code displayed below.
decimal n;
if (!decimal.TryParse(txtRoomH.Text, out n) | !decimal.TryParse(txtRoomW.Text, out n))
{
MessageBox.Show("Please enter numerical values only.");
}
My question is, can someone breakdown and explain what "if (!decimal.TryParse(txtRoomH.Text, out n)" is doing?"
My understanding is slightly vague as to why it works, I just know it works.
Thanks.
Aucun commentaire:
Enregistrer un commentaire