Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


If statement that makes sure ReadLine is a number?

jjpotterjjpotter Posts: 1
I am trying to write a statement that checks that the user input is a Number and not Characters. So something like this:

if (myVariable != //some type to recognize a number)
Console.WriteLine(myLong + " is not a number";
else //continue on with the rest of the program which is:

if (myLong < int.MaxValue)
Console.WriteLine (myLong + " is less than an integer");
else Console.WriteLine("This number " + myLong + " is to large to fit into an integer");

I am very new to programming, only on chapter 3. Not sure if this is the right way to go about this.
Sign In or Register to comment.