I need to check if a variable I have is of the data type double
. This is what I tried:
try
{
double price = Convert.ToDouble(txtPrice.Text);
}
c
So if I get your question right, you mean you only want to allow numbers right? If that's true, then maybe this will help you.
string Str = textBox1.Text.Trim();
double Num;
bool isNum = double.TryParse(Str, out Num);
if (isNum)
MessageBox.Show(Num.ToString());
else
MessageBox.Show("Invalid number");