2
Answers

IsNumeric

roy barlow

roy barlow

17y
2.6k
1
 

I started a course in C# last night. I am trying to program a calculator for a console application. What I am trying to do is test that a value passed isNumeric

The variable is...

string input1;

To convert this to a number I'm using...

number1 = double.Parse(input1);

But I want to test that it's a number before I parse it, I can test for an empty value...

if (input1 == "")

{

Console.WriteLine("Invalid entry.");

goto myLabel_1;

}

But if I try

if (Char.IsNumber(input1)), I get a cannot convert from 'string' to 'char' error.

Any suggestions on how to check that a value is not an alpha character?

Thanks in advance

Answers (2)