I'm receiving some user input through a TextBox
which is then being converted to an int so it can be used in further calculations when I click the Calculate
button.
I have checked to see if the TextBox
is empty when the Calculate
button is clicked, if it is, then a message box appears. Now I realised I need to check to make sure it is a number being input, not a letter. I'm looking for something similar to this
if(hoursInput.Text == "" || hoursInput.Text contains "a-z")
{
\\ handle error
}
else
{
\\ continue with code
}
EDIT:
The user input is converted to an int in the else
block, but I do not want the function to reach this stage of converting from string to int if the user input contains letters, which is why I want to check to see if the user input contains any letters in the if
block