Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
If statement that makes sure ReadLine is a number?
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.
0 · ·